KLReviveTipPanel.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. ---@class KLReviveTipPanel:UIKmlLuaPanelBase
  2. ---@field view KLReviveTipPanelView
  3. local KLReviveTipPanel = class(UIKmlLuaPanelBase)
  4. local this = KLReviveTipPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self.leftcfg = {}
  8. self.rightcfg = {}
  9. end
  10. ---创建或者刷新界面数据时调用
  11. function this:Refresh()
  12. local mapId = SL:GetMetaValue(EMetaVarGetKey.MAP_ID)
  13. if self.args then
  14. GUI:Text_setString(self.view.informationText, "您在<color=#3AB8F1>" .. self.args.place .. "</color>被" .. "<color=#FF0000>" .. self.args.killer .. "</color>" .. "击杀,请选择复活方式。")
  15. if SL:HasConfig("cfg_map_info", self.args.mapId) then
  16. ---@type cfg_map_info_column
  17. local mapcfg = SL:GetConfig("cfg_map_info", self.args.mapId)
  18. ---@type cfg_revive_column
  19. self.leftcfg = SL:GetConfig("cfg_revive", mapcfg.rebirthType[1])
  20. ---@type cfg_revive_column
  21. self.rightcfg = SL:GetConfig("cfg_revive", mapcfg.rebirthType[2])
  22. GUI:Button_setTitleText(self.view.RightBtn,self.rightcfg.name)
  23. self.countDownTimer = tonumber(SL:GetConfig("cfg_global", 116).value)
  24. if self.countDown then
  25. SL:UnSchedule(self.countDown)
  26. self.countDown = nil
  27. end
  28. self.countDown = SL:Schedule(self.countDown,0,1,self.countDownTimer + 1,function()
  29. self:CountDownText()
  30. end)
  31. end
  32. end
  33. end
  34. ---注册UI事件和服务器消息
  35. function this:RegistEvents()
  36. GUI:AddOnClickEvent(self.view.LeftBtn, self, self.OnClickLeftBtn)
  37. GUI:AddOnClickEvent(self.view.RightBtn, self, self.OnClickRightBtn)
  38. SL:RegisterLUAEvent(LUA_EVENT_ME_RELIVE, self.ResReliveMessage, self)
  39. end
  40. --[[--倒计时
  41. this.countDownTimer = 60
  42. function this.CountDownText()
  43. if this.countDownTimer <= 0 then return end
  44. this.countDownTimer = this.countDownTimer - 1
  45. this.obj_text_reviveCountDown:SetText(string.format("回到重生点(%02d)", this.countDownTimer))
  46. if this.countDownTimer <= 0 then
  47. --this:Revive(1)
  48. if this.countDown then
  49. this.registInBaseUI:Stop_Timer(this.countDown)
  50. end
  51. this:HideMe()
  52. end
  53. end]]
  54. --倒计时
  55. function this:CountDownText()
  56. if self.countDownTimer <= 0 then
  57. return
  58. end
  59. self.countDownTimer = self.countDownTimer - 1
  60. GUI:Button_setTitleText(self.view.LeftBtn,string.format("免费复活(%02d)", self.countDownTimer))
  61. --GUI:Text_setString(self.view.LeftBtnText, string.format("免费复活(%02d)", self.countDownTimer))
  62. --self.obj_text_reviveCountDown:SetText(string.format("免费复活(%02d)", self.countDownTimer))
  63. --GUI:setSwallowTouches(self.view.LeftBtn,true)
  64. if self.countDownTimer <= 0 then
  65. --self:Revive(1)
  66. --GUI:setSwallowTouches(self.view.LeftBtn,false)0000
  67. GUI:Button_setTitleText(self.view.LeftBtn,"免费复活")
  68. self:ReviveType(self.leftcfg.id, self.leftcfg.type)
  69. self:OnCloseButton()
  70. if self.countDown then
  71. SL:UnSchedule(self.countDown)
  72. self.countDown = nil
  73. end
  74. end
  75. end
  76. ---通知复活
  77. ---@param message MapProtos.ReliveRes
  78. function this:ResReliveMessage(_, message)
  79. if message.id ~= SL:GetMetaValue(EMetaVarGetKey.UID) then
  80. return
  81. end
  82. SL.AudioMgr.ReviveGame()
  83. self:OnCloseButton()
  84. end
  85. function this:OnCloseButton()
  86. GUI:UIPanel_Close("dev/ui/Revive/Panel/KLReviveTip/KLReviveTipPanel")
  87. end
  88. function this:OnClickLeftBtn()
  89. if self.leftcfg then
  90. self:ReviveType(self.leftcfg.id, self.leftcfg.type)
  91. --self:OnCloseButton()
  92. end
  93. end
  94. function this:OnClickRightBtn()
  95. if self.rightcfg then
  96. self:ReviveType(self.rightcfg.id, self.rightcfg.type)
  97. end
  98. end
  99. function this:ReviveType(id, type)
  100. SL:ReqPlayerReliveMessage(id, type)
  101. --self:OnCloseButton()
  102. end
  103. function this:OnClose()
  104. if self.countDown then
  105. SL:UnSchedule(self.countDown)
  106. self.countDown = nil
  107. end
  108. SL.ShowMainPanel()
  109. end
  110. return this