KLUnionBossTaskPanel.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. ---@class KLUnionBossTaskPanel:UIKmlLuaPanelBase
  2. ---@field view KLUnionBossTaskPanelView
  3. local KLUnionBossTaskPanel = class(UIKmlLuaPanelBase)
  4. local this = KLUnionBossTaskPanel
  5. ---创建时调用一次
  6. function this:Init()
  7. self.tickTimer = SL:Schedule(self.tickTimer, 0, 1, -1, function()
  8. return self:Tick()
  9. end)
  10. end
  11. ---注册UI事件和服务器消息
  12. function this:RegistEvents()
  13. GUI:AddOnClickEvent(self.view.exitBtn, self, self.BtnExitOnClick)
  14. GUI:AddOnClickEvent(self.view.btn_next, self, self.BtnNextOnClick)
  15. GUI:AddOnClickEvent(self.view.btn_auction, self, self.BtnAuctionOnClick)
  16. end
  17. function this:BtnExitOnClick()
  18. local data = { content = "离开副本将丢失进度,是否退出", okFunc = function()
  19. --请求退出副本
  20. SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_EXIT_WAR_ALLIANCE)
  21. end }
  22. GUI:UIPanel_Open("dev/outui/Activity/Panel/KLSure/KLSurePanel", nil, nil, data)
  23. end
  24. function this:BtnNextOnClick()
  25. local curTransConfig = self.transConfigs[self.curLevel]
  26. if not curTransConfig then
  27. return
  28. end
  29. ---@type cfg_transfer_point_column
  30. local transferPoint = SL:GetConfig("cfg_transfer_point", tonumber(string.split(curTransConfig, "#")[2]))
  31. local pos = transferPoint.position
  32. SL:MapMove(pos[1], pos[2])
  33. end
  34. function this:BtnAuctionOnClick()
  35. GUI:UIPanel_Open("dev/outui/Trade/Panel/KLTradeMain/KLTradeMainPanel", nil, nil, "toggle_trade_union")
  36. end
  37. ---创建或者刷新界面数据时调用
  38. function this:Refresh()
  39. self:Tick()
  40. ---@type cfg_repGlobal_column
  41. local config = SL:GetConfig("cfg_repGlobal", 14001001)
  42. local tipStr = string.format("前<color=#4CC5FE>%s</color>个通关的战盟将获得拍卖奖励", config.value)
  43. GUI:Text_setString(self.view.txt_pass_tip, tipStr)
  44. end
  45. function this:Tick()
  46. local endTime = InfoManager.unionBossInfo.dupEndTime
  47. local countdown = SL:SecondToHMS((endTime - SL:GetMetaValue(EMetaVarGetKey.SERVER_TIME)) // 1000)
  48. GUI:Text_setString(self.view.text_end_time, string.format("%02s:%02s", countdown.m, countdown.s))
  49. end
  50. function this:SetData(message)
  51. ---@type cfg_repGlobal_column
  52. local globalConfig = SL:GetConfig("cfg_repGlobal", 14001003)
  53. local value = globalConfig.value
  54. self.transConfigs = string.split(value, "|")
  55. self.curLevel = message.position or self.curLevel
  56. --local curRepMonsterId = tonumber(message.taskId)
  57. local count = #self.transConfigs + 1
  58. --[[while curRepMonsterId ~= 0 do
  59. count = count + 1
  60. ---@type cfg_repMonster_column
  61. local monster = SL:GetConfig("cfg_repMonster",curRepMonsterId)
  62. if monster and monster.nextID ~= 0 then
  63. curRepMonsterId = monster.nextID
  64. else
  65. curRepMonsterId = 0
  66. end
  67. end]]
  68. if message.phrase < count then
  69. GUI:Text_setString(self.view.text_level, string.format("<color=#ff2323>%d</color><color=#1add1f>/%d</color>", message.phrase, count))
  70. else
  71. GUI:Text_setString(self.view.text_level, string.format("<color=#1add1f>%d/%d</color>", message.phrase, count))
  72. end
  73. local forbidPass = message.nowCount < message.totalCount
  74. if forbidPass then
  75. GUI:Text_setString(self.view.text_progress, string.format("<color=#ff2323>%d</color><color=#1add1f>/%d</color>", message.nowCount, message.totalCount))
  76. else
  77. GUI:Text_setString(self.view.text_progress, string.format("<color=#1add1f>%d/%d</color>", message.nowCount, message.totalCount))
  78. end
  79. GUI:setVisible(self.view.btn_next, message.position ~= math.max(message.phrase,message.myCurrPhrase) and message.position < count)
  80. GUI:setVisible(self.view.btn_auction, message.goAuction ~= nil)
  81. end
  82. function this:Close()
  83. if self.tickTimer then
  84. SL:UnSchedule(self.tickTimer)
  85. end
  86. end
  87. return this