UIClimbingTowerBattleView.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. local UIClimbingTowerBattleView = require("UIClimbingTower/UIClimbingTowerBattleView_Generate")
  2. local BattleHeadsBoxPart = require("UIBattle/BattleHeadsBoxPart")
  3. local BattleStatisticsPart = require("UIBattle/BattleStatisticsPart")
  4. local BattleReplayControlPart = require("UIBattle/BattleReplayControlPart")
  5. local NewBattleChatPart = require("UIBattle/NewBattleChatPart")
  6. function UIClimbingTowerBattleView:OnAwake(data)
  7. self.controller = require("UIClimbingTower/UIClimbingTowerBattleCtr"):new()
  8. self.controller:Init(self)
  9. self.controller:SetData(data)
  10. end
  11. function UIClimbingTowerBattleView:AddEventListener()
  12. end
  13. function UIClimbingTowerBattleView:FillContent(data, uiBase)
  14. self.uiBase = uiBase
  15. local gameObject = self.uiBase:GetRoot()
  16. if gameObject ~= nil then
  17. self.gameObject = gameObject
  18. self.transform = gameObject.transform
  19. end
  20. self:InitGenerate(self.transform, data)
  21. self:Init()
  22. end
  23. function UIClimbingTowerBattleView:Init()
  24. local iswj = ManagerContainer.DataMgr.TowerDataMgr:IsWJMode()
  25. if self.NewBattleChatPart == nil then
  26. self.NewBattleChatPart = NewBattleChatPart:new()
  27. end
  28. if self.HeadsBoxPart == nil then
  29. self.HeadsBoxPart = BattleHeadsBoxPart:new()
  30. end
  31. if self.StatisticsPart == nil then
  32. self.StatisticsPart = BattleStatisticsPart:new()
  33. end
  34. if self.battleReplayPart == nil then
  35. self.battleReplayPart = BattleReplayControlPart:new()
  36. end
  37. self.NewBattleChatPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/NewBattleChat"))
  38. self.HeadsBoxPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleHeadsBox"))
  39. self.StatisticsPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleStatistics"))
  40. self.battleReplayPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleReplayControl"))
  41. self.HeadsBoxPart:Show()
  42. self.StatisticsPart:Show(BattleMode.Time,BattleSubMode.ClimbingTower)
  43. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  44. local isPlayRecord,recordLevel = self.controller:GetReplayRecord()
  45. if isPlayRecord then
  46. local levelName =I18N.SetLanguageValue("TopTowerLevel", recordLevel)-- "第" .. recordLevel .. "层"
  47. self.battleReplayPart:Show(levelName)
  48. else
  49. self.battleReplayPart:Hide()
  50. end
  51. if iswj then
  52. self.boardTitle.uILocalizeScript:SetContent('wjTower')
  53. else
  54. self.boardTitle.uILocalizeScript:SetContent('TitleClimbingTower')
  55. end
  56. self.leftFightingTime = self.controller:FightingTime()
  57. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  58. self.leftFightingTimeHandler = ManagerContainer.LuaTimerMgr:AddTimer(1000, -1, self, self.OnShowLeftFightingTime, nil)
  59. end
  60. function UIClimbingTowerBattleView:RemoveEventListener()
  61. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  62. end
  63. function UIClimbingTowerBattleView:AddUIEventListener()
  64. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  65. self.HeadsBoxPart:AddUIEventListener()
  66. self.StatisticsPart:AddUIEventListener()
  67. self.battleReplayPart:AddUIEventListener()
  68. self.NewBattleChatPart:AddUIEventListener()
  69. end
  70. function UIClimbingTowerBattleView:OnHide()
  71. end
  72. function UIClimbingTowerBattleView:OnShow(data)
  73. self.controller:SetData(data)
  74. end
  75. function UIClimbingTowerBattleView:OnClose()
  76. self:ClearLeftFightingTimer()
  77. if self.HeadsBoxPart ~= nil then
  78. self.HeadsBoxPart:Hide()
  79. self.HeadsBoxPart:Dispose()
  80. self.HeadsBoxPart = nil
  81. end
  82. if self.StatisticsPart ~= nil then
  83. self.StatisticsPart:Hide()
  84. self.StatisticsPart:Dispose()
  85. self.StatisticsPart = nil
  86. end
  87. if self.battleReplayPart ~= nil then
  88. self.battleReplayPart:Dispose()
  89. self.battleReplayPart = nil
  90. end
  91. if self.NewBattleChatPart ~= nil then
  92. self.NewBattleChatPart:Dispose()
  93. self.NewBattleChatPart = nil
  94. end
  95. end
  96. function UIClimbingTowerBattleView:OnDispose()
  97. self.controller:OnDispose()
  98. end
  99. function UIClimbingTowerBattleView:OnShowLeftFightingTime()
  100. self.leftFightingTime = self.controller:FightingTime()
  101. if self.leftFightingTime <= 0 then
  102. self.leftFightingTime = 0
  103. self:ClearLeftFightingTimer()
  104. end
  105. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  106. end
  107. function UIClimbingTowerBattleView:ClearLeftFightingTimer()
  108. if self.leftFightingTimeHandler ~= nil then
  109. ManagerContainer.LuaTimerMgr:RemoveTimer(self.leftFightingTimeHandler)
  110. self.leftFightingTimeHandler = nil
  111. end
  112. end
  113. return UIClimbingTowerBattleView