UIWorldBossListCtr.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. local UIWorldBossListCtr = class("UIWorldBossListCtr", require("UICtrBase"))
  2. -- 24 * 60 * 60 * 1000
  3. local OneDay = 86400000
  4. -- 60 * 60 * 1000
  5. local OneHour = 3600000
  6. -- 60 * 1000
  7. local OneMinute = 60000
  8. function UIWorldBossListCtr:Init(view)
  9. self.view = view
  10. end
  11. function UIWorldBossListCtr:SetData(data)
  12. self.asyncIdx = 0
  13. if data == nil then return end
  14. self.data = data
  15. end
  16. function UIWorldBossListCtr:GetAsyncIdx()
  17. self.asyncIdx = self.asyncIdx + 1
  18. return self.asyncIdx
  19. end
  20. function UIWorldBossListCtr:GetData()
  21. return self.data
  22. end
  23. function UIWorldBossListCtr:OnDispose()
  24. self.data = nil
  25. self.view = nil
  26. self.worldBossList = nil
  27. self.nextUpdateTimes = nil
  28. self:ClearWorldBossList()
  29. end
  30. function UIWorldBossListCtr:InitData()
  31. self:RefreshWorldBossList()
  32. self:RefreshCurLevel()
  33. self:RefreshMaxCount()
  34. end
  35. function UIWorldBossListCtr:ClearWorldBossList()
  36. ManagerContainer.DataMgr.WorldBossData:ClearWorldBossList()
  37. end
  38. function UIWorldBossListCtr:RefreshWorldBossList()
  39. self.worldBossList = ManagerContainer.DataMgr.WorldBossData:GetWorldBossList()
  40. self:RefreshNextUpdateTimes()
  41. end
  42. function UIWorldBossListCtr:GetWorldBossList()
  43. return self.worldBossList
  44. end
  45. function UIWorldBossListCtr:GetWorldBossByItemIndex(itemIndex)
  46. return self.worldBossList and self.worldBossList[itemIndex + 1] or nil
  47. end
  48. function UIWorldBossListCtr:RefreshCurLevel()
  49. self.curLevelId = ManagerContainer.LuaBattleMgr:GetCurLevelUniqueId()
  50. end
  51. function UIWorldBossListCtr:GetCurLevelId()
  52. return self.curLevelId
  53. end
  54. function UIWorldBossListCtr:GetChallengeCount()
  55. return ManagerContainer.DataMgr.WorldBossData:GetWorldBossCount()
  56. end
  57. function UIWorldBossListCtr:RefreshNextUpdateTimes()
  58. if not self.worldBossList then return end
  59. local num = #self.worldBossList
  60. if num <= 0 then return end
  61. local curTime = ManagerContainer.LuaTimerMgr:CurLuaServerTime()
  62. for i = 1, num do
  63. self:RefreshNextUpdateTime(self.worldBossList[i], i, curTime)
  64. end
  65. end
  66. function UIWorldBossListCtr:RefreshNextUpdateTime(worldBossData, idx, curTime)
  67. local nextUpdateTime = 0
  68. local remainTime = 0
  69. if worldBossData then
  70. if int64.__lt(0, worldBossData.expireTime) then
  71. remainTime = (worldBossData.expireTime - curTime)
  72. nextUpdateTime = self:CalcNextUpdateTime(remainTime, curTime)
  73. elseif int64.__lt(0, worldBossData.nextTime) then
  74. remainTime = (worldBossData.nextTime - curTime)
  75. nextUpdateTime = self:CalcNextUpdateTime(remainTime, curTime)
  76. end
  77. end
  78. self:SetNextUpdateTime(idx, nextUpdateTime)
  79. -- return remainTime
  80. end
  81. function UIWorldBossListCtr:CalcNextUpdateTime(remainTime, curTime)
  82. if int64.__le(OneDay, remainTime) then
  83. local validTime = remainTime % OneHour
  84. if int64.equals(validTime, 0) then validTime = OneHour end
  85. return curTime + validTime
  86. elseif int64.__le(OneHour, remainTime) then
  87. local validTime = remainTime % OneMinute
  88. if int64.equals(validTime, 0) then validTime = OneMinute end
  89. return curTime + validTime
  90. elseif int64.__le(0, remainTime) then
  91. local validTime = remainTime % 1000
  92. if int64.equals(validTime, 0) then validTime = 1000 end
  93. return curTime + validTime
  94. else
  95. return 0
  96. end
  97. end
  98. function UIWorldBossListCtr:GetNextUpdateTime(itemIndex)
  99. if not self.nextUpdateTimes then return nil end
  100. return self.nextUpdateTimes[itemIndex]
  101. end
  102. function UIWorldBossListCtr:SetNextUpdateTime(itemIndex, time)
  103. if not self.nextUpdateTimes then
  104. self.nextUpdateTimes = {}
  105. end
  106. self.nextUpdateTimes[itemIndex] = time
  107. end
  108. function UIWorldBossListCtr:RefreshMaxCount()
  109. local maxCount = GlobalConfig.Instance:GetConfigIntValue(154)
  110. local vipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
  111. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
  112. if vipCfg and vipCfg.WorldBossCount and vipCfg.WorldBossCount >= 1 then
  113. maxCount = maxCount + vipCfg.WorldBossCount
  114. end
  115. self.maxCount = maxCount
  116. end
  117. function UIWorldBossListCtr:GetMaxCount()
  118. return self.maxCount
  119. end
  120. --- 获得世界boss列表
  121. ---@return integer 0:发送成功;1:客户端限制发送
  122. function UIWorldBossListCtr:SendRefreshBossListReq()
  123. return ManagerContainer.DataMgr.WorldBossData:SendWorldBossListRequest()
  124. end
  125. function UIWorldBossListCtr:SendChallengeBossReq(bossId, bossSummonIdx)
  126. ManagerContainer.DataMgr.WorldBossData:SendChallengeBossRequest(bossId, bossSummonIdx)
  127. end
  128. return UIWorldBossListCtr