KLRedFortCounterPanel.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. ---@class KLRedFortCounterPanel:UIKmlLuaPanelBase
  2. ---@field view KLRedFortCounterPanelView
  3. ---@field killCount number
  4. ---@field dieCount number
  5. ---@field hideTime number
  6. local KLRedFortCounterPanel = class(UIKmlLuaPanelBase)
  7. local this = KLRedFortCounterPanel
  8. ---创建时调用一次
  9. function this:Init()
  10. SL:KeepOpenPanel("KLRedFortCounterPanelKml",true)
  11. end
  12. ---注册UI事件和服务器消息
  13. function this:RegistEvents()
  14. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RED_FORTRESS_KILL_RELIVE, self.RES_RED_FORTRESS_KILL_RELIVE, self)
  15. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_QUIT_DUPLICATE, self.RES_QUIT_DUPLICATE, self)
  16. end
  17. ----{}
  18. function this:RES_RED_FORTRESS_KILL_RELIVE(_, message)
  19. self.hideTime = 5
  20. local type = message["1"]
  21. local count = tostring(message["2"])
  22. if type == 1 then
  23. GUI:SetActive(self.view.dieCount, false)
  24. GUI:SetActive(self.view.killCount, true)
  25. GUI:Text_setString(self.view.textKillCount, count)
  26. elseif type == 2 then
  27. GUI:SetActive(self.view.dieCount, true)
  28. GUI:SetActive(self.view.killCount, false)
  29. GUI:Text_setString(self.view.textDieCount, count)
  30. end
  31. if not self.timer then
  32. self.timer = SL:StartLoopForever(1, self.RefreshText, self) ---Timer.StartLoopForever(1, self.RefreshText, self)
  33. end
  34. self:RefreshText()
  35. end
  36. function this:RefreshText()
  37. if self.hideTime <= 0 then
  38. GUI:SetActive(self.view.dieCount, false)
  39. GUI:SetActive(self.view.killCount, false)
  40. if self.timer then
  41. ---Timer.Stop(self.timer)
  42. SL:UnSchedule(self.timer)
  43. self.timer = nil
  44. end
  45. return
  46. end
  47. self.hideTime = self.hideTime - 1
  48. end
  49. function this:RES_QUIT_DUPLICATE()
  50. GUI:UI_Close("dev/outui/Activity/Panel/KLRedFortCounter/KLRedFortCounterPanel")
  51. end
  52. ---创建或者刷新界面数据时调用
  53. function this:Refresh()
  54. self.killCount = 0
  55. self.dieCount = 0
  56. self.hideTime = 5
  57. end
  58. function this:Close()
  59. if self.timer then
  60. ---Timer.Stop(self.timer)
  61. SL:UnSchedule(self.timer)
  62. self.timer = nil
  63. end
  64. end
  65. return this