UIGuildHuntCtr.lua 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. local UIGuildHuntCtr = class("UIGuildHuntCtr", require("UICtrBase"))
  2. function UIGuildHuntCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIGuildHuntCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. self:InitData()
  9. end
  10. function UIGuildHuntCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UIGuildHuntCtr:GetData()
  15. return self.data
  16. end
  17. function UIGuildHuntCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. if self.guildData then
  21. self.guildData:ClearHuntBoss()
  22. end
  23. self.guildData = nil
  24. self.curBossIdx = nil
  25. self.bossListNum = nil
  26. self.bossList = nil
  27. end
  28. function UIGuildHuntCtr:InitData()
  29. self.guildData = ManagerContainer.DataMgr.GuildDataMgr:GetCurGuildData()
  30. self.bossList = nil
  31. self.curBossIdx = nil
  32. end
  33. function UIGuildHuntCtr:GetGuildMinePost()
  34. return self.guildData:GetGuildMemberPost(ManagerContainer.DataMgr.UserData:GetUserId())
  35. end
  36. function UIGuildHuntCtr:GetGuildLv()
  37. local briefData = self.guildData:GetBriefData()
  38. return briefData and briefData.level or 0
  39. end
  40. function UIGuildHuntCtr:RefreshBossList()
  41. local ls = {}
  42. local lastSelectBoss = nil
  43. if self.bossList then
  44. if self.curBossIdx then
  45. lastSelectBoss = self.bossList[self.curBossIdx]
  46. if lastSelectBoss then
  47. lastSelectBoss = lastSelectBoss.Id
  48. end
  49. elseif self.data then
  50. lastSelectBoss = self.data
  51. end
  52. else
  53. lastSelectBoss = self.data
  54. end
  55. local cfgDatas = ManagerContainer.CfgMgr:GetGuildHuntBossCfg()
  56. if cfgDatas then
  57. for id, value in pairs(cfgDatas) do
  58. if self.guildData:GetHuntBossInfoById(id) then
  59. ls[#ls + 1] = value
  60. end
  61. end
  62. end
  63. table.sort(ls, function (a, b)
  64. return a.Id < b.Id
  65. end)
  66. local num = #ls
  67. local curBossIdx = nil
  68. if lastSelectBoss then
  69. for i = 1, num do
  70. if ls[i].Id == lastSelectBoss then
  71. curBossIdx = i
  72. break
  73. end
  74. end
  75. end
  76. if curBossIdx then
  77. self.curBossIdx = curBossIdx
  78. else
  79. if num > 0 then
  80. self.curBossIdx = 1
  81. else
  82. self.curBossIdx = nil
  83. end
  84. end
  85. self.bossListNum = num
  86. self.bossList = ls
  87. end
  88. function UIGuildHuntCtr:ContainBoss(id)
  89. if not self.bossList then return false end
  90. for _, value in pairs(self.bossList) do
  91. if value.Id == id then
  92. return true
  93. end
  94. end
  95. return false
  96. end
  97. function UIGuildHuntCtr:GetBossInfoList()
  98. return self.bossList
  99. end
  100. function UIGuildHuntCtr:GetCurGuildActive()
  101. local briefData = self.guildData:GetBriefData()
  102. return briefData and briefData.active or 0
  103. end
  104. function UIGuildHuntCtr:CanMove()
  105. if not self.curBossIdx or not self.bossListNum or self.bossListNum <= 0 then
  106. return false, false
  107. end
  108. return (self.curBossIdx > 1), (self.curBossIdx < self.bossListNum)
  109. end
  110. function UIGuildHuntCtr:GetCurBossId()
  111. if not self.bossList then return nil end
  112. local curBossCfgData = self.bossList[self.curBossIdx]
  113. if curBossCfgData then
  114. return curBossCfgData.Id
  115. end
  116. return nil
  117. end
  118. function UIGuildHuntCtr:GetCurBossInfo()
  119. if not self.bossList then return nil, nil end
  120. local curBossCfgData = self.bossList[self.curBossIdx]
  121. if curBossCfgData then
  122. return curBossCfgData, self.guildData:GetHuntBossInfoById(curBossCfgData.Id)
  123. end
  124. return nil, nil
  125. end
  126. function UIGuildHuntCtr:GetHuntBossCd()
  127. return self.guildData:GetHuntBossCd()
  128. end
  129. function UIGuildHuntCtr:ChangeBoss(next)
  130. if self.bossListNum <= 0 then return false end
  131. local newBossIdx = nil
  132. if next then
  133. newBossIdx = self.curBossIdx + 1
  134. else
  135. newBossIdx = self.curBossIdx - 1
  136. end
  137. if newBossIdx <= 0 then
  138. return false
  139. end
  140. if newBossIdx > self.bossListNum then
  141. return false
  142. end
  143. self.curBossIdx = newBossIdx
  144. return true
  145. end
  146. function UIGuildHuntCtr:GetNearNeedUpdateRemainTime()
  147. if not self.bossList then return 0 end
  148. local remainTime = nil
  149. for _, value in pairs(self.bossList) do
  150. local bossData = self.guildData:GetHuntBossInfoById(value.Id)
  151. if bossData then
  152. if bossData.fightTime and bossData.fightTime > 0 then
  153. local newRemainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightTime + 2000)
  154. if newRemainTime > 0 then
  155. if not remainTime or remainTime > newRemainTime then
  156. remainTime = newRemainTime
  157. end
  158. end
  159. elseif bossData.fightCdTime and bossData.fightCdTime > 0 then
  160. local newRemainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime + 2000)
  161. if newRemainTime > 0 then
  162. if not remainTime or remainTime > newRemainTime then
  163. remainTime = newRemainTime
  164. end
  165. end
  166. end
  167. end
  168. end
  169. return remainTime
  170. end
  171. function UIGuildHuntCtr:ExtraChallengeNum()
  172. local vipLv = ManagerContainer.DataMgr.UserData:GetVipLv()
  173. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(vipLv)
  174. --LogError("================vipLv ======" .. vipLv)
  175. return vipCfg and vipCfg.GuildBossChallenge or 0
  176. end
  177. function UIGuildHuntCtr:ExtraBoliVipChallengeNum()
  178. local vipLv = ManagerContainer.DataMgr.BoliShopData:GetCurLv()
  179. local vipCfg = ManagerContainer.CfgMgr:GetBoLiVipCfgById(vipLv)
  180. --LogError("================vipLv ======" .. vipLv)
  181. return vipCfg and vipCfg.GuildBossChallenge or 0
  182. end
  183. function UIGuildHuntCtr:ChallengeBoss()
  184. local bossId = self:GetCurBossId()
  185. if not bossId then
  186. return
  187. end
  188. ManagerContainer.DataMgr.GuildDataMgr:StartGuildHuntBattle(bossId)
  189. end
  190. function UIGuildHuntCtr:SendGuildHuntBossListInfoReq()
  191. if not ManagerContainer.DataMgr.GuildDataMgr:SendGuildHuntBossListInfoReq() then
  192. return 100007
  193. end
  194. return 0
  195. end
  196. function UIGuildHuntCtr:SendGuildHuntBossSummonReq()
  197. if not ManagerContainer.DataMgr.GuildDataMgr:SendGuildHuntBossSummonReq(self:GetCurBossId()) then
  198. return 100007
  199. end
  200. return 0
  201. end
  202. return UIGuildHuntCtr