UIClimbingTowerBattleView.lua 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. if self.NewBattleChatPart == nil then
  25. self.NewBattleChatPart = NewBattleChatPart:new()
  26. end
  27. if self.HeadsBoxPart == nil then
  28. self.HeadsBoxPart = BattleHeadsBoxPart:new()
  29. end
  30. if self.StatisticsPart == nil then
  31. self.StatisticsPart = BattleStatisticsPart:new()
  32. end
  33. if self.battleReplayPart == nil then
  34. self.battleReplayPart = BattleReplayControlPart:new()
  35. end
  36. self.NewBattleChatPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/NewBattleChat"))
  37. self.HeadsBoxPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleHeadsBox"))
  38. self.StatisticsPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleStatistics"))
  39. self.battleReplayPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleReplayControl"))
  40. self.HeadsBoxPart:Show()
  41. self.StatisticsPart:Show(BattleMode.Time,BattleSubMode.ClimbingTower)
  42. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  43. local isPlayRecord,recordLevel = self.controller:GetReplayRecord()
  44. if isPlayRecord then
  45. local levelName = "第" .. recordLevel .. "层"
  46. self.battleReplayPart:Show(levelName)
  47. else
  48. self.battleReplayPart:Hide()
  49. end
  50. self.leftFightingTime = self.controller:FightingTime()
  51. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  52. self.leftFightingTimeHandler = ManagerContainer.LuaTimerMgr:AddTimer(1000, -1, self, self.OnShowLeftFightingTime, nil)
  53. end
  54. function UIClimbingTowerBattleView:RemoveEventListener()
  55. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  56. end
  57. function UIClimbingTowerBattleView:AddUIEventListener()
  58. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  59. self.HeadsBoxPart:AddUIEventListener()
  60. self.StatisticsPart:AddUIEventListener()
  61. self.battleReplayPart:AddUIEventListener()
  62. self.NewBattleChatPart:AddUIEventListener()
  63. end
  64. function UIClimbingTowerBattleView:OnHide()
  65. end
  66. function UIClimbingTowerBattleView:OnShow(data)
  67. self.controller:SetData(data)
  68. end
  69. function UIClimbingTowerBattleView:OnClose()
  70. self:ClearLeftFightingTimer()
  71. if self.HeadsBoxPart ~= nil then
  72. self.HeadsBoxPart:Hide()
  73. self.HeadsBoxPart:Dispose()
  74. self.HeadsBoxPart = nil
  75. end
  76. if self.StatisticsPart ~= nil then
  77. self.StatisticsPart:Hide()
  78. self.StatisticsPart:Dispose()
  79. self.StatisticsPart = nil
  80. end
  81. if self.battleReplayPart ~= nil then
  82. self.battleReplayPart:Dispose()
  83. self.battleReplayPart = nil
  84. end
  85. if self.NewBattleChatPart ~= nil then
  86. self.NewBattleChatPart:Dispose()
  87. self.NewBattleChatPart = nil
  88. end
  89. end
  90. function UIClimbingTowerBattleView:OnDispose()
  91. self.controller:OnDispose()
  92. end
  93. function UIClimbingTowerBattleView:OnShowLeftFightingTime()
  94. self.leftFightingTime = self.controller:FightingTime()
  95. if self.leftFightingTime <= 0 then
  96. self.leftFightingTime = 0
  97. self:ClearLeftFightingTimer()
  98. end
  99. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  100. end
  101. function UIClimbingTowerBattleView:ClearLeftFightingTimer()
  102. if self.leftFightingTimeHandler ~= nil then
  103. ManagerContainer.LuaTimerMgr:RemoveTimer(self.leftFightingTimeHandler)
  104. self.leftFightingTimeHandler = nil
  105. end
  106. end
  107. return UIClimbingTowerBattleView