KLUIExpMessagePanel.lua 982 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---@class KLUIExpMessagePanel:UIKmlLuaPanelBase
  2. ---@field view KLUIExpMessagePanelView
  3. local KLUIExpMessagePanel = class(UIKmlLuaPanelBase)
  4. local this =KLUIExpMessagePanel
  5. ---创建时调用一次
  6. function this:Init()
  7. SL:KeepOpenPanel("KLUIExpMessagePanelKml",true)
  8. end
  9. ---创建或者刷新界面数据时调用
  10. function this:Refresh()
  11. end
  12. ---注册UI事件和服务器消息
  13. function this:RegistEvents()
  14. SL:RegisterLuaNetMsg(LuaMessageIdToClient.BOBBLE_POINT_SHOW,self.BubbleExpMsg,self)
  15. end
  16. ---@param message {exp:number,expAddRate:number,fromType:number 是否泡点}
  17. function this:BubbleExpMsg(_,message)
  18. if message then
  19. local text
  20. if message.fromType == 1 then
  21. text = string.format("*#EXP %d(+%d%%)",message.exp,math.floor(message.expAddRate/100 + 0.5),"%")
  22. else
  23. text = string.format("EXP %d(+%d%%)",message.exp,math.floor(message.expAddRate/100 + 0.5),"%")
  24. end
  25. SL:ExpTipMessage(text,nil,nil,2.5)
  26. end
  27. end
  28. function this:Close()
  29. end
  30. return this