UIExpeditionBattleView.lua 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. local UIExpeditionBattleView = require("UIExpedition/UIExpeditionBattleView_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 UIExpeditionBattleView:OnAwake(data)
  7. self.controller = require("UIExpedition/UIExpeditionBattleCtr"):new()
  8. self.controller:Init(self)
  9. self.controller:SetData(data)
  10. end
  11. function UIExpeditionBattleView:AddEventListener()
  12. end
  13. function UIExpeditionBattleView: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 UIExpeditionBattleView:Init()
  24. if self.HeadsBoxPart == nil then
  25. self.HeadsBoxPart = BattleHeadsBoxPart:new()
  26. end
  27. if self.StatisticsPart == nil then
  28. self.StatisticsPart = BattleStatisticsPart:new()
  29. end
  30. if self.NewBattleChatPart == nil then
  31. self.NewBattleChatPart = NewBattleChatPart:new()
  32. end
  33. self.NewBattleChatPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/NewBattleChat"))
  34. self.HeadsBoxPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleHeadsBox"))
  35. self.StatisticsPart:InitGo(self,self.uiBase:FindChildGo("UIBattle/BattleStatistics"))
  36. self.HeadsBoxPart:Show()
  37. --远征之门延迟打开导致同步事件没有触发 这里打开时同步HP SP (之后缓存消息队列)
  38. self:RefreshHeadsBoxPartHpSp()
  39. self.StatisticsPart:Show(BattleMode.Time,BattleSubMode.Expedition)
  40. self.StatisticsPart:SetCanvasOrder(self.uiBase.SortingOrder-1)
  41. self.leftFightingTime = ManagerContainer.LuaTimeBattleMgr:GetLeftFightingTime()
  42. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  43. self.leftFightingTimeHandler = ManagerContainer.LuaTimerMgr:AddTimer(1000, -1, self, self.OnShowLeftFightingTime, nil)
  44. local mapData = ManagerContainer.DataMgr.ExpeditionDataMgr:CurChallengingMap()
  45. if mapData ~= nil then
  46. self.mapName.text.text = mapData.name
  47. self.curLevel.text.text = tostring(ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurLevelId()) .. "/" .. mapData.maxLevelNum
  48. end
  49. end
  50. function UIExpeditionBattleView:RefreshHeadsBoxPartHpSp()
  51. local ourMembers = LuaBattleBridge.GetBattleTeamPlayerActors()
  52. for i =1, ourMembers.Count do
  53. local actor = ourMembers[i-1]
  54. local hpPercent,spPercent = ManagerContainer.DataMgr.ExpeditionDataMgr:GetHeroHPAndSP(actor.ID)
  55. local curhp = hpPercent * 0.01 * SDataUtil.InvConvert(actor.Life)
  56. local cursp = spPercent * 0.01 * SDataUtil.InvConvert(actor.Sp)
  57. self.HeadsBoxPart:RefreshFighterLife(actor.ID,curhp,actor.Life)
  58. self.HeadsBoxPart:RefreshFighterSp(actor.ID,cursp,actor.Sp)
  59. end
  60. end
  61. function UIExpeditionBattleView:RemoveEventListener()
  62. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  63. end
  64. function UIExpeditionBattleView:AddUIEventListener()
  65. self.HeadsBoxPart:AddUIEventListener()
  66. self.StatisticsPart:AddUIEventListener()
  67. self.NewBattleChatPart:AddUIEventListener()
  68. end
  69. function UIExpeditionBattleView:OnHide()
  70. end
  71. function UIExpeditionBattleView:OnShow(data)
  72. self.controller:SetData(data)
  73. end
  74. function UIExpeditionBattleView:OnClose()
  75. self:ClearLeftFightingTimer()
  76. if self.HeadsBoxPart ~= nil then
  77. self.HeadsBoxPart:Hide()
  78. self.HeadsBoxPart:Dispose()
  79. self.HeadsBoxPart = nil
  80. end
  81. if self.StatisticsPart ~= nil then
  82. self.StatisticsPart:Hide()
  83. self.StatisticsPart:Dispose()
  84. self.StatisticsPart = nil
  85. end
  86. if self.NewBattleChatPart ~= nil then
  87. self.NewBattleChatPart:Dispose()
  88. self.NewBattleChatPart = nil
  89. end
  90. end
  91. function UIExpeditionBattleView:OnDispose()
  92. self.controller:OnDispose()
  93. end
  94. function UIExpeditionBattleView:OnShowLeftFightingTime()
  95. self.leftFightingTime = ManagerContainer.LuaTimeBattleMgr:GetLeftFightingTime()
  96. if self.leftFightingTime <= 0 then
  97. self:ClearLeftFightingTimer()
  98. end
  99. self.leftTime.text.text = FormatTimeMS(self.leftFightingTime)
  100. end
  101. function UIExpeditionBattleView:ClearLeftFightingTimer()
  102. if self.leftFightingTimeHandler ~= nil then
  103. ManagerContainer.LuaTimerMgr:RemoveTimer(self.leftFightingTimeHandler)
  104. self.leftFightingTimeHandler = nil
  105. end
  106. end
  107. return UIExpeditionBattleView