UIVipExpTipsView.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. local UIVipExpTipsView = require("UIVip/UIVipExpTipsView_Generate")
  2. function UIVipExpTipsView:OnAwake(data)
  3. self.controller = require("UIVip/UIVipExpTipsCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIVipExpTipsView:AddEventListener()
  8. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  9. end
  10. function UIVipExpTipsView:FillContent(data, uiBase)
  11. self.uiBase = uiBase
  12. local gameObject = self.uiBase:GetRoot()
  13. if gameObject ~= nil then
  14. self.gameObject = gameObject
  15. self.transform = gameObject.transform
  16. end
  17. self:InitGenerate(self.transform, data)
  18. self:Init()
  19. end
  20. function UIVipExpTipsView:Init()
  21. self:RefreshView()
  22. end
  23. function UIVipExpTipsView:RemoveEventListener()
  24. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  25. end
  26. function UIVipExpTipsView:AddUIEventListener()
  27. end
  28. function UIVipExpTipsView:OnHide()
  29. end
  30. function UIVipExpTipsView:OnShow(data)
  31. self.controller:SetData(data)
  32. end
  33. function UIVipExpTipsView:OnClose()
  34. end
  35. function UIVipExpTipsView:OnDispose()
  36. if self.animTimer then
  37. self.animTimer:Stop()
  38. self.animTimer = nil
  39. end
  40. if self.closeTimer then
  41. self.closeTimer:Stop()
  42. self.closeTimer = nil
  43. end
  44. self.controller:OnDispose()
  45. end
  46. function UIVipExpTipsView:RefreshView()
  47. local curLv, lastExp, curExp = self.controller:GetInfo()
  48. local vipExp = 1
  49. local vipCfg = ManagerContainer.CfgMgr:GetVipCfgById(curLv)
  50. self.vipIcon.image.sprite = nil
  51. self.vipIcon.image.enabled = false
  52. if vipCfg then
  53. self.vipNameTxt.text.text = string.formatbykey(vipCfg.Name)
  54. CommonUtil.LoadIcon(self, vipCfg.SmallIcon, function(sprite)
  55. if sprite then
  56. self.vipIcon.image.sprite = sprite
  57. self.vipIcon.image.enabled = true
  58. end
  59. end)
  60. vipExp = vipCfg.VipExp or 0
  61. else
  62. self.vipNameTxt.text.text = ''
  63. end
  64. vipExp = Mathf.Max(vipExp, lastExp, curExp)
  65. self.addNum.text.text = '+' .. tostring(curExp - lastExp)
  66. self.slider1.slider.value = (curExp / vipExp)
  67. self.slider2.slider.value = (lastExp / vipExp)
  68. self.number.text.text = tostring(curExp) .. '/' .. tostring(vipExp)
  69. if self.animTimer then
  70. self.animTimer:Stop()
  71. self.animTimer = nil
  72. end
  73. self.animTimer = Timer.New(function()
  74. self.slider2.slider:DOValue((curExp / vipExp), 1)
  75. end, 0.5)
  76. self.animTimer:Start()
  77. if self.closeTimer then
  78. self.closeTimer:Stop()
  79. self.closeTimer = nil
  80. end
  81. self.closeTimer = Timer.New(function()
  82. self:CheckNextChange()
  83. end, 2.3)
  84. self.closeTimer:Start()
  85. self.vipExpAnim.animator:Play('FightPowerShow', -1, 0)
  86. self.vipExpAnim.animator:Update(0)
  87. end
  88. function UIVipExpTipsView:CheckNextChange()
  89. local isNext = self.controller:RefreshNextChange()
  90. if not isNext then
  91. self:UIClose()
  92. return
  93. end
  94. self:RefreshView()
  95. end
  96. return UIVipExpTipsView