UIBigMapView.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. local UIBigMapView = require("UIBigMap/UIBigMapView_Generate")
  2. local BigMapView = require("UIBigMap/BigMapView")
  3. local UIBattleCtr = ManagerContainer.LuaUIMgr:GetViewCtrById(Enum.UIPageName.UIBattle)
  4. function UIBigMapView:OnAwake(data)
  5. self.controller = require("UIBigMap/UIBigMapCtr"):new()
  6. self.controller:Init(self)
  7. self.controller:SetData(data)
  8. end
  9. function UIBigMapView:AddEventListener()
  10. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.EID_LEVEL_CHANGED, self, self.OnLevelChanged)
  11. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.BIGMAP_SELF_RANK_CHANGED, self, self.OnSelfRankChanged)
  12. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name, UIEventNames.UI_PAGE_IN_END_NTF, self, self.OnUIPageInEndNtf)
  13. end
  14. function UIBigMapView:FillContent(data, uiBase)
  15. self.uiBase = uiBase
  16. local gameObject = self.uiBase:GetRoot()
  17. if gameObject ~= nil then
  18. self.gameObject = gameObject
  19. self.transform = gameObject.transform
  20. end
  21. self:InitGenerate(self.transform, data)
  22. self:Init()
  23. end
  24. function UIBigMapView:Init()
  25. if not self.bigMapView then
  26. self.bigMapView = BigMapView:new(self)
  27. end
  28. local curMapId = self.controller:GetCurMapId()
  29. local curLevelId = self.controller:GetCurLevelId()
  30. local mapId = self.controller:GetMapId()
  31. local enterType = self.controller:GetEnterType()
  32. self.bigMapView:InitData(curMapId, curLevelId, mapId, enterType)
  33. if enterType == Enum.BigMapEnterType.Default then
  34. self.btnBack:SetActive(true)
  35. self.btnBigMap:SetActive(true)
  36. else
  37. self.btnBack:SetActive(false)
  38. self.btnBigMap:SetActive(false)
  39. end
  40. self:RefreshMap()
  41. if self.delayFrameTimer then
  42. self.delayFrameTimer:Stop()
  43. self.delayFrameTimer = nil
  44. end
  45. self.delayFrameTimer = FrameTimer.New(function()
  46. local boxPos = UIBattleCtr:GetMiniMapPosition()
  47. if boxPos then
  48. self.window.transform.position = boxPos
  49. end
  50. LuaBattleBridge.BeginTweenPosition(self.window, 0.15, Vector3.zero, false)
  51. end, 1)
  52. self.delayFrameTimer:Start()
  53. self.awardTips:SetActive(false)
  54. ManagerContainer.LuaUIMgr:Hide(Enum.UIPageName.UIBattle)
  55. end
  56. function UIBigMapView:RemoveEventListener()
  57. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  58. end
  59. function UIBigMapView:AddUIEventListener()
  60. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  61. self.uiBase:AddButtonUniqueEventListener(self.btnBack.button, self, self.OnClickBtnBack)
  62. self.uiBase:AddButtonUniqueEventListener(self.btnBigMap.button, self, self.OnClickBtnBigMap)
  63. self.uiBase:AddButtonUniqueEventListener(self.awardTips.AnyBtn.button, self, self.OnClickBtnAlpha)
  64. end
  65. function UIBigMapView:OnHide()
  66. end
  67. function UIBigMapView:OnShow(data)
  68. self.controller:SetData(data)
  69. end
  70. function UIBigMapView:OnClose()
  71. end
  72. function UIBigMapView:OnDispose()
  73. if self.delayFrameTimer then
  74. self.delayFrameTimer:Stop()
  75. self.delayFrameTimer = nil
  76. end
  77. if self.bigMapView then
  78. self.bigMapView:Dispose()
  79. self.bigMapView = nil
  80. end
  81. self.isWaitBattleOpen = nil
  82. end
  83. function UIBigMapView:OnSelfRankChanged()
  84. if self.bigMapView then
  85. self.bigMapView:RefreshSelfRank()
  86. end
  87. end
  88. function UIBigMapView:OnLevelChanged()
  89. self.controller:RefreshLevelData()
  90. if self.bigMapView then
  91. local curMapId = self.controller:GetCurMapId()
  92. local curLevelId = self.controller:GetCurLevelId()
  93. local mapId = self.controller:GetMapId()
  94. self.bigMapView:OnLevelChanged(curMapId, curLevelId, mapId)
  95. end
  96. end
  97. function UIBigMapView:OnUIPageInEndNtf(id)
  98. if not self.isWaitBattleOpen then return end
  99. if id ~= Enum.UIPageName.UIBattle then return end
  100. self.window.transform.localPosition = Vector3.zero
  101. local boxPos = UIBattleCtr:GetMiniMapPosition()
  102. if boxPos then
  103. boxPos = self.window.transform.parent:InverseTransformPoint(boxPos)
  104. else
  105. boxPos = Vector3.zero
  106. end
  107. LuaBattleBridge.BeginTweenPosition(self.window, 0.15, boxPos, false)
  108. self.super.UIClose(self)
  109. self.isWaitBattleOpen = false
  110. end
  111. function UIBigMapView:RefreshMap()
  112. local mapData = self.controller:GetMapData()
  113. if mapData then
  114. local mapName = mapData.Name
  115. if ManagerContainer.LuaBattleMgr:IsShowDifficultyTxt() then
  116. mapName = I18N.T(ManagerContainer.LuaBattleMgr:CurLevelQianZhuiKey())..(mapName and I18N.SetLanguageValue(mapName) or '')
  117. else
  118. mapName = (mapName and I18N.SetLanguageValue(mapData.Name) or '')
  119. end
  120. self.nameTxt.text.text = mapName
  121. end
  122. end
  123. function UIBigMapView:UIClose()
  124. self.isWaitBattleOpen = true
  125. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIBattle, nil, nil, nil, true)
  126. end
  127. function UIBigMapView:BigMapViewComplete(hasFollow)
  128. self:UIClose()
  129. end
  130. function UIBigMapView:OnPageInEnd()
  131. if self.bigMapView then
  132. self.bigMapView:OnPageInEnd()
  133. end
  134. if self.delayFrameTimer then
  135. self.delayFrameTimer:Stop()
  136. self.delayFrameTimer = nil
  137. end
  138. LuaBattleBridge.BeginTweenPosition(self.window, 0, Vector3.zero, false)
  139. self.super.OnPageInEnd(self)
  140. end
  141. function UIBigMapView:OnClickBtnBack()
  142. self:UIClose()
  143. end
  144. function UIBigMapView:OnClickBtnBigMap()
  145. ManagerContainer.LuaUIMgr:Open(Enum.UIPageName.UIWorldMap)
  146. ManagerContainer.LuaUIMgr:ClosePage(self.uiData.id, false)
  147. end
  148. function UIBigMapView:OnClickBtnAlpha()
  149. self.awardTips:SetActive(false)
  150. end
  151. return UIBigMapView