UIClimbingTowerBattleFailedView.lua 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. local UIClimbingTowerBattleFailedView = require("UIClimbingTower/UIClimbingTowerBattleFailedView_Generate")
  2. function UIClimbingTowerBattleFailedView:OnAwake(data)
  3. self.controller = require("UIClimbingTower/UIClimbingTowerBattleFailedCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIClimbingTowerBattleFailedView:AddEventListener()
  8. end
  9. function UIClimbingTowerBattleFailedView:FillContent(data, uiBase)
  10. self.uiBase = uiBase
  11. local gameObject = self.uiBase:GetRoot()
  12. if gameObject ~= nil then
  13. self.gameObject = gameObject
  14. self.transform = gameObject.transform
  15. end
  16. self:InitGenerate(self.transform, data)
  17. self:Init()
  18. end
  19. function UIClimbingTowerBattleFailedView:Init()
  20. for i = 1, 3 do
  21. local go = self:GetTipsGo(i)
  22. if go ~= nil then
  23. go:SetActive(false)
  24. end
  25. end
  26. local fromPageId = self.controller:GetData()
  27. local tips = nil
  28. if fromPageId == Enum.UIPageName.UISkillExpBattle then
  29. tips = ManagerContainer.BattleFailedTipsMgr:CheckShowTips(3,2)
  30. self.reopenBtn:SetActive(true)
  31. elseif fromPageId == Enum.UIPageName.UIClimbingTower then
  32. local type = ManagerContainer.DataMgr.PeakTowerDataMgr:GetCurUITowerType()
  33. if type == Enum.UnlimitTowerType.PeakTower then
  34. tips = ManagerContainer.BattleFailedTipsMgr:CheckShowTips(3,2)
  35. self.reopenBtn:SetActive(false)
  36. else
  37. tips = ManagerContainer.BattleFailedTipsMgr:CheckShowTips(3,2)
  38. self.reopenBtn:SetActive(true)
  39. end
  40. elseif fromPageId == Enum.UIPageName.UIBattle then
  41. tips = ManagerContainer.BattleFailedTipsMgr:CheckShowTips(3,1)
  42. self.reopenBtn:SetActive(false)
  43. end
  44. if tips ~= nil then
  45. for i = 1, #tips do
  46. local tip = tips[i]
  47. local node = self:GetTipsGo(i)
  48. self:SetTipData(node,tip)
  49. end
  50. end
  51. end
  52. function UIClimbingTowerBattleFailedView:SetTipData(node,tip)
  53. if node == nil then
  54. return
  55. end
  56. if tip.TipsIcon ~= nil and tip.TipsIcon ~= "" then
  57. CommonUtil.LoadIcon(self, tip.TipsIcon, function (sprite)
  58. node.tipsIcon.image.sprite = sprite
  59. end)
  60. end
  61. node.tipsContent.text.text = I18N.T(tip.Content)
  62. if tip.GotoPageIds ~= nil and #tip.GotoPageIds > 0 then
  63. node.btnGo:SetActive(true)
  64. self.uiBase:AddButtonUniqueEventListener(node.btnGo.button, self, self.OnClickJump, tip.GotoPageIds,tip.params,tip.LoadPageCondition)
  65. else
  66. node.btnGo:SetActive(false)
  67. end
  68. node:SetActive(true)
  69. end
  70. function UIClimbingTowerBattleFailedView:OnClickJump(btn,params)
  71. local fromPageId = self.controller:GetData()
  72. if fromPageId == Enum.UIPageName.UISkillExpBattle then
  73. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,nil)
  74. elseif fromPageId == Enum.UIPageName.UIClimbingTower then
  75. local type = ManagerContainer.DataMgr.PeakTowerDataMgr:GetCurUITowerType()
  76. if type == Enum.UnlimitTowerType.PeakTower then
  77. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_PVPCIMBINGBATTLE,nil)
  78. else
  79. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,nil)
  80. end
  81. end
  82. ManagerContainer.LuaUIMgr:ClosePage(self.uiBase.PageId)
  83. local allPageIds = params[0]
  84. local extendParams = params[1]
  85. local loadPageConds = params[2]
  86. local pageIds = nil
  87. if extendParams == nil or extendParams == 1 then
  88. pageIds = allPageIds[1]
  89. else
  90. pageIds = allPageIds[2]
  91. end
  92. if pageIds ~= nil then
  93. if type(pageIds) == "table" then
  94. for i=1, #pageIds do
  95. local parentId = 0
  96. if i > 1 then
  97. parentId = pageIds[i-1]
  98. end
  99. if self:CheckPageCanOpen(pageIds[i],loadPageConds) then
  100. self:OpenGoPage(parentId,pageIds[i],extendParams)
  101. end
  102. end
  103. else
  104. if self:CheckPageCanOpen(pageIds,loadPageConds) then
  105. self:OpenGoPage(nil,pageIds,extendParams)
  106. end
  107. end
  108. end
  109. end
  110. function UIClimbingTowerBattleFailedView:CheckPageCanOpen(pageId,loadPageConds)
  111. if loadPageConds == nil then
  112. return true
  113. end
  114. for i=1, #loadPageConds do
  115. local conds = loadPageConds[i]
  116. if conds[1] == pageId then
  117. return conds[2] > 0
  118. end
  119. end
  120. return true
  121. end
  122. function UIClimbingTowerBattleFailedView:OpenGoPage(parentPageId,pageID,params)
  123. local uiData = ManagerContainer.CfgMgr:GetUIData(pageID)
  124. if uiData.type == 0 then
  125. if not ManagerContainer.LuaUIMgr:HasOpenPage(pageID) then
  126. if not ManagerContainer.LuaUIMgr:HasOpenPage(Enum.UIPageName.UIMain) then
  127. ManagerContainer.LuaUIMgr:Back2NormalBattleMain(uiData.mainViewType)
  128. else
  129. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UIMAINVIEW_CHANGE_NOTICE, uiData.mainViewType, params)
  130. end
  131. ManagerContainer.LuaUIMgr:Open(pageID,params)
  132. end
  133. else
  134. if pageID == Enum.UIPageName.UISkillSettings then
  135. params = {params}
  136. end
  137. ManagerContainer.LuaUIMgr:Open(pageID,params,parentPageId)
  138. end
  139. end
  140. function UIClimbingTowerBattleFailedView:RemoveEventListener()
  141. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  142. end
  143. function UIClimbingTowerBattleFailedView:AddUIEventListener()
  144. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickClose)
  145. self.uiBase:AddButtonEventListener(self.reopenBtn.button,self, self.OnClickReopen)
  146. end
  147. function UIClimbingTowerBattleFailedView:OnHide()
  148. end
  149. function UIClimbingTowerBattleFailedView:OnShow(data)
  150. self.controller:SetData(data)
  151. end
  152. function UIClimbingTowerBattleFailedView:OnClose()
  153. end
  154. function UIClimbingTowerBattleFailedView:OnDispose()
  155. self.controller:OnDispose()
  156. end
  157. function UIClimbingTowerBattleFailedView:OnClickClose()
  158. local fromPageId = self.controller:GetData()
  159. if fromPageId == Enum.UIPageName.UISkillExpBattle then
  160. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,fromPageId)
  161. elseif fromPageId == Enum.UIPageName.UIClimbingTower then
  162. local type = ManagerContainer.DataMgr.PeakTowerDataMgr:GetCurUITowerType()
  163. if type == Enum.UnlimitTowerType.PeakTower then
  164. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_PVPCIMBINGBATTLE,fromPageId)
  165. else
  166. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,fromPageId)
  167. end
  168. elseif fromPageId == Enum.UIPageName.UIBattle then
  169. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.UI_FORCE_GUIDE_OVER, true)
  170. end
  171. ManagerContainer.LuaUIMgr:ClosePage(self.uiBase.PageId)
  172. end
  173. function UIClimbingTowerBattleFailedView:OnClickReopen()
  174. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,nil)
  175. self.controller:ReEnterBattle()
  176. end
  177. function UIClimbingTowerBattleFailedView:GetTipsGo(idx)
  178. if idx == 1 then
  179. return self.tips1
  180. elseif idx == 2 then
  181. return self.tips2
  182. elseif idx == 3 then
  183. return self.tips3
  184. end
  185. return nil
  186. end
  187. return UIClimbingTowerBattleFailedView