UIWorldBossBattleCtr.lua 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. local UIWorldBossBattleCtr = class("UIWorldBossBattleCtr", require("UICtrBase"))
  2. function UIWorldBossBattleCtr:Init(view)
  3. self.view = view
  4. end
  5. function UIWorldBossBattleCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self:InitBossData()
  8. if data == nil then return end
  9. self.data = data
  10. end
  11. function UIWorldBossBattleCtr:GetAsyncIdx()
  12. self.asyncIdx = self.asyncIdx + 1
  13. return self.asyncIdx
  14. end
  15. function UIWorldBossBattleCtr:GetData()
  16. return self.data
  17. end
  18. function UIWorldBossBattleCtr:OnDispose()
  19. self.data = nil
  20. self.view = nil
  21. self.bossName = nil
  22. self.bossIcon = nil
  23. self.hpSegment = nil
  24. self.bossLife = nil
  25. self.bossMaxLife = nil
  26. self.bossLifeBarNum = nil
  27. self.bossSegmentPrecent = nil
  28. end
  29. function UIWorldBossBattleCtr:InitBossData()
  30. local worldBossCfgData = ManagerContainer.DataMgr.WorldBossData:GetWorldBossDataById(self:GetCfgId(),0)
  31. if nil == worldBossCfgData then
  32. worldBossCfgData = ManagerContainer.DataMgr.WorldBossData:GetWorldBossDataById(self:GetCfgId(),1)
  33. end
  34. if worldBossCfgData then
  35. self.hpSegment = worldBossCfgData.HpSegment
  36. local summonId = worldBossCfgData.SummonId
  37. local npcCfgData = ManagerContainer.CfgMgr:GetNpcCfgById(summonId)
  38. if npcCfgData then
  39. self.bossName = npcCfgData.Name
  40. self.bossIcon = npcCfgData.Head
  41. end
  42. end
  43. self:SyncBossLife()
  44. end
  45. function UIWorldBossBattleCtr:GetCfgId()
  46. return ManagerContainer.DataMgr.WorldBossData:GetBattleBossId()
  47. end
  48. function UIWorldBossBattleCtr:GetHpSegment()
  49. return self.hpSegment or 1
  50. end
  51. function UIWorldBossBattleCtr:SyncBossLife()
  52. local life = ManagerContainer.DataMgr.WorldBossData:GetCurHp()
  53. local maxLife = ManagerContainer.DataMgr.WorldBossData:GetMaxHp()
  54. life = Mathf.Min(Mathf.Max(life, 0), maxLife)
  55. if self.bossLife == life and self.bossMaxLife == maxLife then
  56. return false
  57. end
  58. self.bossLife = life
  59. self.bossMaxLife = maxLife
  60. local hpSegment = self:GetHpSegment()
  61. local segmentMaxLife = maxLife / hpSegment
  62. local segmentRemainderLifeNum = Mathf.Ceil(life / segmentMaxLife)
  63. local segmentRemainderLife = life % segmentMaxLife
  64. if segmentRemainderLifeNum > 0 then
  65. if segmentRemainderLife <= 0 then
  66. segmentRemainderLife = segmentMaxLife
  67. end
  68. end
  69. local segmentPrecent = segmentRemainderLife / segmentMaxLife
  70. self.bossLifeBarNum = segmentRemainderLifeNum
  71. self.bossSegmentPrecent = segmentPrecent
  72. return true
  73. end
  74. function UIWorldBossBattleCtr:GetBossName()
  75. return self.bossName
  76. end
  77. function UIWorldBossBattleCtr:GetBossIcon()
  78. return self.bossIcon
  79. end
  80. function UIWorldBossBattleCtr:GetBossInitSkillParam()
  81. return ManagerContainer.LuaBossBattleMgr.bossSkillParam
  82. end
  83. function UIWorldBossBattleCtr:GetBossLifeBarNum()
  84. return self.bossLifeBarNum
  85. end
  86. function UIWorldBossBattleCtr:GetBossSegmentPrecent()
  87. return self.bossSegmentPrecent
  88. end
  89. function UIWorldBossBattleCtr:GetDefaultInBattleUIds()
  90. return ManagerContainer.DataMgr.WorldBossData:GetDefaultInBattleUIds()
  91. end
  92. function UIWorldBossBattleCtr:GetActorSystemByUID(uuid)
  93. return ManagerContainer.DataMgr.WorldBossData:GetActorSystemByUID(uuid)
  94. end
  95. function UIWorldBossBattleCtr:GetCurUserId()
  96. return ManagerContainer.DataMgr.UserData:GetUserId()
  97. end
  98. function UIWorldBossBattleCtr:SetWorldBossBattleUIReady()
  99. return ManagerContainer.DataMgr.WorldBossData:WorldBossBattleUIReady()
  100. end
  101. return UIWorldBossBattleCtr