UIGuildHuntView.lua 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. local UIGuildHuntView = require("UIGuild/UIGuildHuntView_Generate")
  2. local PreviewSystem = require("PreviewSystem")
  3. function UIGuildHuntView:OnAwake(data)
  4. self.controller = require("UIGuild/UIGuildHuntCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIGuildHuntView:AddEventListener()
  9. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_DISBAND_SUCCESS, self, self.OnGuildDisBandSuccess)
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_QUIT_SUCCESS, self, self.OnGuildQuitSuccess)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_KICKOUT_SUCCESS, self, self.OnGuildKickoutSuccess)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_HUNT_BOSS_LIST_CHANGED, self, self.OnGuildHuntBossListChanged)
  13. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.GUILD_HUNT_BOSS_SUMMON_CHANGED, self, self.OnGuildHuntBossSummonChanged)
  14. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.VIP_LV_CHANGED, self, self.OnVipLvChanged)
  15. end
  16. function UIGuildHuntView:FillContent(data, uiBase)
  17. self.uiBase = uiBase
  18. local gameObject = self.uiBase:GetRoot()
  19. if gameObject ~= nil then
  20. self.gameObject = gameObject
  21. self.transform = gameObject.transform
  22. end
  23. self:InitGenerate(self.transform, data)
  24. self:Init()
  25. end
  26. function UIGuildHuntView:Init()
  27. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.RED_POINT_MGR_NOTICE, Enum.RPNotifyType.GuildHuntBoss, false)
  28. if not self.previewSystem then
  29. self.previewSystem = PreviewSystem:new('GuildHuntPreview')
  30. self.previewSystem:SetView(Vector3(0, 1.93, 4.75), Quaternion.Euler(0, 180, 0))
  31. else
  32. self.previewSystem:RemoveAllGo()
  33. end
  34. self.bossImg.rawImage.texture = self.previewSystem:GetRenderTexture()
  35. self:RefreshModel()
  36. self:RefreshView()
  37. self.controller:SendGuildHuntBossListInfoReq()
  38. end
  39. function UIGuildHuntView:RemoveEventListener()
  40. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  41. end
  42. function UIGuildHuntView:AddUIEventListener()
  43. self.uiBase:AddButtonUniqueEventListener(self.btnPlayRule.button, self, self.OnClickPlayRuleBtn)
  44. self.uiBase:AddButtonUniqueEventListener(self.btnAward.button, self, self.OnClickAwardBtn)
  45. self.uiBase:AddButtonUniqueEventListener(self.btnLeft.button, self, self.OnClickLeftBtn)
  46. self.uiBase:AddButtonUniqueEventListener(self.btnRight.button, self, self.OnClickRightBtn)
  47. self.uiBase:AddButtonUniqueEventListener(self.btnBack.button, self, self.OnClickBackBtn)
  48. self.uiBase:AddButtonUniqueEventListener(self.btnLog.button, self, self.OnClickLogBtn)
  49. self.uiBase:AddButtonUniqueEventListener(self.btnChallenge.button, self, self.OnClickChallengeBtn)
  50. self.uiBase:AddButtonUniqueEventListener(self.btnSummon.button, self, self.OnClickSummonBtn)
  51. end
  52. function UIGuildHuntView:OnHide()
  53. end
  54. function UIGuildHuntView:OnShow(data)
  55. self.controller:SetData(data)
  56. end
  57. function UIGuildHuntView:OnClose()
  58. end
  59. function UIGuildHuntView:OnDispose()
  60. self:DisposeModel()
  61. if self.previewSystem then
  62. self.previewSystem:Dispose()
  63. self.previewSystem = nil
  64. end
  65. self:DisposeRefreshTimer()
  66. self:DisposeRefreshInfoTimer()
  67. self.controller:OnDispose()
  68. end
  69. function UIGuildHuntView:OnGuildDisBandSuccess()
  70. self.uiBase.MSourceUIID = 0
  71. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  72. end
  73. function UIGuildHuntView:OnGuildQuitSuccess()
  74. self.uiBase.MSourceUIID = 0
  75. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  76. end
  77. function UIGuildHuntView:OnGuildKickoutSuccess()
  78. self.uiBase.MSourceUIID = 0
  79. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  80. end
  81. function UIGuildHuntView:OnGuildHuntBossListChanged()
  82. self.controller:RefreshBossList()
  83. self:RefreshModel()
  84. self:RefreshView()
  85. self:StartRefreshInfoTimer()
  86. end
  87. function UIGuildHuntView:OnGuildHuntBossSummonChanged(bossId)
  88. if not self.controller:ContainBoss(bossId) then
  89. self.controller:RefreshBossList()
  90. self:RefreshModel()
  91. end
  92. self:RefreshView()
  93. end
  94. function UIGuildHuntView:OnVipLvChanged()
  95. self:RefreshView()
  96. end
  97. function UIGuildHuntView:OnClickPlayRuleBtn()
  98. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIPlayRule, {'PlayExplainTitle', 'GuildBossPlayExplain'})
  99. end
  100. function UIGuildHuntView:OnClickAwardBtn()
  101. local bossId = self.controller:GetCurBossId()
  102. if not bossId then
  103. return
  104. end
  105. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildHuntMasterReward, bossId)
  106. end
  107. function UIGuildHuntView:OnClickLeftBtn()
  108. if not self.controller:ChangeBoss(false) then
  109. return
  110. end
  111. self:RefreshModel()
  112. self:RefreshView()
  113. end
  114. function UIGuildHuntView:OnClickRightBtn()
  115. if not self.controller:ChangeBoss(true) then
  116. return
  117. end
  118. self:RefreshModel()
  119. self:RefreshView()
  120. end
  121. function UIGuildHuntView:OnClickBackBtn()
  122. ManagerContainer.LuaUIMgr:OpenSourceUI(self)
  123. end
  124. function UIGuildHuntView:OnClickChallengeBtn()
  125. local data = self.controller:GetBossInfoList()
  126. if not data then
  127. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
  128. return
  129. end
  130. local bossCfgData, bossData = self.controller:GetCurBossInfo()
  131. if not bossCfgData or not bossData then
  132. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
  133. return
  134. end
  135. local maxNum = bossCfgData.Challenge or 0
  136. if bossCfgData.BossType == Enum.GuildHuntBossType.Normal then
  137. maxNum = maxNum + self.controller:ExtraChallengeNum() + self.controller:ExtraBoliVipChallengeNum()
  138. end
  139. local remainNum = bossData.remainNum or 0
  140. if remainNum >= maxNum then
  141. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(587)
  142. return
  143. end
  144. if bossCfgData.BossType ~= Enum.GuildHuntBossType.Normal then
  145. local cd = self.controller:GetHuntBossCd()
  146. if cd then
  147. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(cd)
  148. if remainTime > 0 then
  149. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam('GuildTips_045', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, true))
  150. return
  151. end
  152. end
  153. end
  154. self.controller:ChallengeBoss()
  155. end
  156. function UIGuildHuntView:OnClickSummonBtn()
  157. local errorCode = self.controller:SendGuildHuntBossSummonReq()
  158. if errorCode ~= 0 then
  159. ManagerContainer.LuaUIMgr:ErrorNoticeDisplay(errorCode)
  160. end
  161. end
  162. function UIGuildHuntView:OnClickLogBtn()
  163. local bossId = self.controller:GetCurBossId()
  164. if not bossId then
  165. return
  166. end
  167. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIGuildHuntLog, bossId)
  168. end
  169. function UIGuildHuntView:OnClickSkillItem(_, params)
  170. local skillId = params[0]
  171. local skillLv = params[1]
  172. ManagerContainer.LuaUIMgr:OpenTips({tipsType = Enum.UITipsType.Skill, cfgId = skillId, num = skillLv})
  173. end
  174. function UIGuildHuntView:OnClickIconItem(_, params)
  175. local data = params[0]
  176. ManagerContainer.LuaUIMgr:OpenTips(data)
  177. end
  178. function UIGuildHuntView:RefreshView()
  179. local data = self.controller:GetBossInfoList()
  180. if not data then
  181. self.bossName:SetActive(false)
  182. self.timer:SetActive(false)
  183. self.btnAward:SetActive(false)
  184. self.btnLeft:SetActive(false)
  185. self.btnRight:SetActive(false)
  186. self.skillList:SetActive(false)
  187. self.awardScrollView:SetActive(false)
  188. self.btnChallenge:SetActive(false)
  189. self.btnSummon:SetActive(false)
  190. self.costBox:SetActive(false)
  191. self.condBox:SetActive(false)
  192. self.btnLog:SetActive(false)
  193. return
  194. end
  195. local canLeft, canRight = self.controller:CanMove()
  196. self.btnLeft:SetActive(canLeft)
  197. self.btnRight:SetActive(canRight)
  198. local bossCfgData, bossData = self.controller:GetCurBossInfo()
  199. if not bossCfgData or not bossData then
  200. self.bossName:SetActive(false)
  201. self.timer:SetActive(false)
  202. self.btnAward:SetActive(false)
  203. self.skillList:SetActive(false)
  204. self.awardScrollView:SetActive(false)
  205. self.btnChallenge:SetActive(false)
  206. self.btnSummon:SetActive(false)
  207. self.costBox:SetActive(false)
  208. self.condBox:SetActive(false)
  209. self.btnLog:SetActive(false)
  210. self:StopRefreshTimer()
  211. return
  212. end
  213. self.bossName:SetActive(true)
  214. self.btnAward:SetActive((bossCfgData.BossType == Enum.GuildHuntBossType.Normal and bossCfgData.MasterReward and #bossCfgData.MasterReward > 0))
  215. self.skillList:SetActive(true)
  216. self.btnLog:SetActive(true)
  217. local post = self.controller:GetGuildMinePost()
  218. local summonAuth = IsTableHasValue(bossCfgData.SummonLimit, post)
  219. if bossCfgData.UnlockCond > self.controller:GetGuildLv() then
  220. self.timer:SetActive(false)
  221. self:StopRefreshTimer()
  222. self.costBox:SetActive(false)
  223. self.condBox:SetActive(true)
  224. self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_035', tostring(bossCfgData.UnlockCond))
  225. if summonAuth then
  226. self.btnChallenge:SetActive(false)
  227. self.btnSummon:SetActive(true)
  228. self.btnSummon.button.interactable = false
  229. else
  230. self.btnChallenge:SetActive(true)
  231. self.btnChallenge.button.interactable = false
  232. self.btnSummon:SetActive(false)
  233. end
  234. elseif bossData.fightTime and bossData.fightTime > 0 then
  235. self.timer:SetActive(true)
  236. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightTime)
  237. self.timeTxt.text.text = string.formatbykey('OutTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  238. self:StartRefreshTimer()
  239. local maxNum = bossCfgData.Challenge or 0
  240. if bossCfgData.BossType == Enum.GuildHuntBossType.Normal then
  241. --LogError("=============BossType================="..self.controller:ExtraChallengeNum())
  242. maxNum = maxNum + self.controller:ExtraChallengeNum() + self.controller:ExtraBoliVipChallengeNum()
  243. end
  244. local remainNum = bossData.remainNum or 0
  245. self.costBox:SetActive(false)
  246. self.condBox:SetActive(true)
  247. self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_034', tostring(maxNum - remainNum))
  248. self.btnChallenge:SetActive(true)
  249. self.btnChallenge.button.interactable = true
  250. self.btnSummon:SetActive(false)
  251. -- elseif bossData.fightCdTime and bossData.fightCdTime > 0 then
  252. -- local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
  253. -- -- self.timeTxt.text.text = string.formatbykey('InTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  254. -- -- self:StartRefreshTimer()
  255. -- -- self.btnChallenge:SetActive(false)
  256. -- -- self.btnSummon:SetActive(false)
  257. -- self.timer:SetActive(false)
  258. -- self:StopRefreshTimer()
  259. -- if bossCfgData.BossType == Enum.GuildHuntBossType.Normal or not summonAuth then
  260. -- self.btnChallenge:SetActive(true)
  261. -- self.btnChallenge.button.interactable = true
  262. -- self.btnSummon:SetActive(false)
  263. -- self.costBox:SetActive(true)
  264. -- local maxNum = bossCfgData.Challenge or 0
  265. -- local remainNum = bossData.remainNum or 0
  266. -- self.costBox.number.text.text = string.formatbykey('GuildInfo_034', tostring(maxNum - remainNum))
  267. -- self.condBox:SetActive(false)
  268. -- else
  269. -- self.btnChallenge:SetActive(false)
  270. -- self.btnSummon:SetActive(true)
  271. -- self.btnSummon.button.interactable = false
  272. -- end
  273. else
  274. if bossData.fightCdTime and bossData.fightCdTime > 0 then
  275. local remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
  276. self.timeTxt.text.text = string.formatbykey('GuildInfo_039', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  277. self.timer:SetActive(true)
  278. self:StartRefreshTimer()
  279. else
  280. self.timer:SetActive(false)
  281. self:StopRefreshTimer()
  282. end
  283. if bossCfgData.BossType == Enum.GuildHuntBossType.Normal or not summonAuth then
  284. self.btnChallenge:SetActive(true)
  285. self.btnChallenge.button.interactable = false
  286. self.btnSummon:SetActive(false)
  287. self.costBox:SetActive(false)
  288. self.condBox:SetActive(true)
  289. self.condBox.condTxt.text.text = string.formatbykey('GuildInfo_036')
  290. else
  291. self.btnChallenge:SetActive(false)
  292. self.btnSummon:SetActive(true)
  293. self.costBox:SetActive(true)
  294. local active = self.controller:GetCurGuildActive()
  295. if (bossCfgData.Consume > active) then
  296. self.btnSummon.button.interactable = false
  297. self.costBox.number.text.text = string.format(Constant.RedColorText, (tostring(active) .. '/' .. tostring(bossCfgData.Consume)))
  298. else
  299. self.btnSummon.button.interactable = true
  300. self.costBox.number.text.text = string.format(Constant.GreenColorText, (tostring(active) .. '/' .. tostring(bossCfgData.Consume)))
  301. end
  302. self.condBox:SetActive(false)
  303. end
  304. end
  305. local npcId = bossCfgData.SummonId
  306. local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(npcId)
  307. local skillInfos = nil
  308. if npcCfgData then
  309. skillInfos = npcCfgData.SkillIds
  310. self.bossName.text.text = string.formatbykey(npcCfgData.Name)
  311. else
  312. self.bossName.text.text = ''
  313. end
  314. for i = 1, 4 do
  315. local skillItem = self['skillItem' .. i]
  316. if skillItem then
  317. local skillInfo = skillInfos and skillInfos[i] or nil
  318. if not skillInfo then
  319. skillItem:SetActive(false)
  320. else
  321. skillItem:SetActive(true)
  322. local skillId = skillInfo[1]
  323. local skillLv = skillInfo[2]
  324. local skillCfgData = ManagerContainer.CfgMgr:GetSkillCfgByType(Enum.SkillType.Active, skillId, skillLv)
  325. if skillCfgData then
  326. skillItem.icon.image.enabled = false
  327. skillItem.icon.image.sprite = nil
  328. CommonUtil.LoadIcon(self, skillCfgData.Icon, function (sprite)
  329. skillItem.icon.image.enabled = true
  330. skillItem.icon.image.sprite = sprite
  331. end, skillItem, "SkillIconAsyncIdx")
  332. self.uiBase:AddButtonUniqueEventListener(skillItem.icon.button, self, self.OnClickSkillItem, skillId, skillLv)
  333. else
  334. skillItem.icon.image.enabled = false
  335. skillItem.icon.image.sprite = nil
  336. skillItem.icon.button:RemoveAllListeners()
  337. end
  338. skillItem.num.text.text = (I18N.SetLanguageValue('Lv') .. tostring(skillLv)) or ''
  339. end
  340. end
  341. end
  342. local awards = bossCfgData.ReviewAwards
  343. if not awards then
  344. self.awardScrollView:SetActive(false)
  345. return
  346. end
  347. self.awardScrollView:SetActive(true)
  348. CommonUtil.LoopGridViewEleCreateNew(self, self.awardScrollView.loopHorizontalScrollRect, nil, awards, 0, self, self.UpdateAwardItem)
  349. end
  350. function UIGuildHuntView:UpdateAwardItem(itemLua, idx, itemData)
  351. if not itemLua or not itemData then return end
  352. CommonUtil.UpdateItemPrefab(self, itemLua, {cfgId = itemData, num = 0}, Enum.ItemIEnterType.Bag, self, self.OnClickIconItem)
  353. end
  354. function UIGuildHuntView:RefreshModel()
  355. self:DisposeModel()
  356. local data = self.controller:GetBossInfoList()
  357. if not data then
  358. return
  359. end
  360. local bossCfgData, bossData = self.controller:GetCurBossInfo()
  361. if not bossCfgData or not bossData then
  362. return
  363. end
  364. local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(bossCfgData.SummonId)
  365. if not npcCfgData then
  366. return
  367. end
  368. local avatarCfgData = ManagerContainer.CfgMgr:GetAvatarCfgById(npcCfgData.AvatarId)
  369. if not avatarCfgData then
  370. return
  371. end
  372. self.modelPath = avatarCfgData.AvatarPrefab
  373. self.modelPos = CommonUtil.TableToVector3(bossCfgData.ShowPos)
  374. self.modelRot = CommonUtil.TableToQuaternion(bossCfgData.ShowRot)
  375. self.seqId = ManagerContainer.ResMgr:LuaLoadAssets(Enum.ResourceType.GameObject, Constants.ModelPath, {self.modelPath}, self, self.ShowModel)
  376. end
  377. function UIGuildHuntView:ShowModel()
  378. self.modelGo = ManagerContainer.ResMgr:GetGoFromPool(Constants.ModelPath, self.modelPath)
  379. if self.previewSystem then
  380. self.previewSystem:AddGo(self.modelGo)
  381. end
  382. if ManagerContainer.LuaModelMgr and ManagerContainer.LuaModelMgr.ModelRoot then
  383. self.modelGo.transform:SetParent(ManagerContainer.LuaModelMgr.ModelRoot.transform)
  384. end
  385. if self.modelPos then
  386. self.modelGo.transform.localPosition = self.modelPos
  387. end
  388. if self.modelRot then
  389. self.modelGo.transform.localRotation = self.modelRot
  390. end
  391. end
  392. function UIGuildHuntView:DisposeModel()
  393. if self.seqId then
  394. ManagerContainer.ResMgr:ClearUIAsyncLoadReqsBySeqId(self.seqId)
  395. end
  396. self.seqId = nil
  397. if self.modelGo then
  398. ManagerContainer.ResMgr:RecycleGO(Constants.ModelPath, self.modelPath, self.modelGo)
  399. if self.previewSystem then
  400. self.previewSystem:RemoveGo(self.modelGo)
  401. end
  402. end
  403. self.modelPath = nil
  404. self.modelGo = nil
  405. end
  406. function UIGuildHuntView:StartRefreshTimer()
  407. local timer = self.refreshTimer
  408. if not timer then
  409. timer = Timer.New(function()
  410. self:RefreshTimer()
  411. end, 1, -1)
  412. self.refreshTimer = timer
  413. end
  414. if not timer.running then
  415. timer:Start()
  416. end
  417. end
  418. function UIGuildHuntView:StopRefreshTimer()
  419. if self.refreshTimer then
  420. self.refreshTimer:Stop()
  421. end
  422. end
  423. function UIGuildHuntView:DisposeRefreshTimer()
  424. self:StopRefreshTimer()
  425. self.refreshTimer = nil
  426. end
  427. function UIGuildHuntView:RefreshTimer()
  428. local bossCfgData, bossData = self.controller:GetCurBossInfo()
  429. if not bossCfgData or not bossData then
  430. self:StopRefreshTimer()
  431. return
  432. end
  433. local remainTime = nil
  434. if bossData.fightTime and bossData.fightTime > 0 then
  435. remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightTime)
  436. self.timeTxt.text.text = I18N.SetLanguageValue('OutTime1', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  437. elseif bossData.fightCdTime and bossData.fightCdTime > 0 then
  438. remainTime = ManagerContainer.LuaTimerMgr:GetRemainSecondsWithUInt64(bossData.fightCdTime)
  439. self.timeTxt.text.text = I18N.SetLanguageValue('GuildInfo_039', DateTimeUtil.convertSeconds2TimeStr1(remainTime, true, true, false))
  440. else
  441. self.timeTxt.text.text = ''
  442. end
  443. if not remainTime or remainTime <= 0 then
  444. self:StopRefreshTimer()
  445. else
  446. if self.refreshTimer then
  447. local validTime = nil
  448. if remainTime >= 86400 then
  449. validTime = remainTime % 3600
  450. if validTime == 0 then validTime = 3600 end
  451. elseif remainTime >= 3600 then
  452. validTime = remainTime % 60
  453. if validTime == 0 then validTime = 60 end
  454. else
  455. validTime = 1
  456. end
  457. if validTime then
  458. self.refreshTimer.duration = validTime
  459. else
  460. self:StopRefreshTimer()
  461. end
  462. end
  463. end
  464. end
  465. function UIGuildHuntView:StartRefreshInfoTimer()
  466. -- 获得最近倒计时要结束的时间
  467. local remainTime = self.controller:GetNearNeedUpdateRemainTime()
  468. if not remainTime or remainTime <= 0 then
  469. self:StopRefreshInfoTimer()
  470. return
  471. end
  472. local timer = self.refreshInfoTimer
  473. if not timer then
  474. timer = Timer.New(function()
  475. self:RefreshInfoTimer()
  476. end, remainTime)
  477. self.refreshInfoTimer = timer
  478. else
  479. timer.duration = remainTime
  480. timer.time = remainTime
  481. end
  482. if not timer.running then
  483. timer:Start()
  484. end
  485. end
  486. function UIGuildHuntView:StopRefreshInfoTimer()
  487. if self.refreshInfoTimer then
  488. self.refreshInfoTimer:Stop()
  489. end
  490. end
  491. function UIGuildHuntView:RefreshInfoTimer()
  492. self.controller:SendGuildHuntBossListInfoReq()
  493. end
  494. function UIGuildHuntView:DisposeRefreshInfoTimer()
  495. self:StopRefreshInfoTimer()
  496. self.refreshInfoTimer = nil
  497. end
  498. return UIGuildHuntView