UIExpeditionWinView.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. local UIExpeditionWinView = require("UIExpedition/UIExpeditionWinView_Generate")
  2. function UIExpeditionWinView:OnAwake(data)
  3. self.controller = require("UIExpedition/UIExpeditionWinCtr"):new()
  4. self.controller:Init(self)
  5. self.controller:SetData(data)
  6. end
  7. function UIExpeditionWinView:AddEventListener()
  8. end
  9. function UIExpeditionWinView:FillContent(data, uiBase)
  10. self.uiBase = uiBase
  11. local gameObject = self.uiBase:GetRoot()
  12. if gameObject ~= nil then
  13. self.gameObject = gameObject
  14. self.transform = gameObject.transform
  15. end
  16. self:InitGenerate(self.transform, data)
  17. self:Init()
  18. end
  19. function UIExpeditionWinView:Init()
  20. self:ShowBuffList()
  21. end
  22. function UIExpeditionWinView:RemoveEventListener()
  23. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  24. end
  25. function UIExpeditionWinView:AddUIEventListener()
  26. end
  27. function UIExpeditionWinView:OnHide()
  28. end
  29. function UIExpeditionWinView:OnShow(data)
  30. self.controller:SetData(data)
  31. end
  32. function UIExpeditionWinView:OnClose()
  33. end
  34. function UIExpeditionWinView:OnClickClose()
  35. if self.controller:InBattling() then
  36. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,Enum.UIPageName.UIExpedition,true)
  37. end
  38. self:UIClose()
  39. end
  40. function UIExpeditionWinView:OnDispose()
  41. self.controller:OnDispose()
  42. end
  43. function UIExpeditionWinView:ShowBuffList()
  44. local buffs = self.controller:GetBuffs()
  45. if buffs == nil or #buffs == 0 then
  46. self.rewardNode:SetActive(false)
  47. self.winTipsNode:SetActive(true)
  48. self.scoreReward:SetActive(true)
  49. self:RefreshScore()
  50. self.uiBase:AddButtonEventListener(self.AnyBtn.button,self, self.OnClickClose)
  51. else
  52. self.winTipsNode:SetActive(false)
  53. self.rewardNode:SetActive(true)
  54. self.scoreReward:SetActive(false)
  55. for i = 1, 3 do
  56. local buffNode = self:GetBuffNode(i)
  57. buffNode:SetActive(false)
  58. end
  59. for i = 1, #buffs do
  60. local buffNode = self:GetBuffNode(i)
  61. self:SetBuffData(buffNode,buffs[i])
  62. end
  63. local name,score = ManagerContainer.DataMgr.ExpeditionDataMgr:GetLastMonsterNameScore()
  64. if name and score then
  65. ManagerContainer.LuaUIMgr:ErrorNoticeDisplayWithParam("Expeditionmonster", name, tostring(score))
  66. end
  67. end
  68. end
  69. function UIExpeditionWinView:GetBuffNode(idx)
  70. if idx == 1 then
  71. return self.buff1
  72. elseif idx == 2 then
  73. return self.buff2
  74. elseif idx == 3 then
  75. return self.buff3
  76. end
  77. end
  78. function UIExpeditionWinView:RefreshScore()
  79. --是否新纪录
  80. local IsNewRecord = ManagerContainer.DataMgr.ExpeditionDataMgr:IsNewRecord()
  81. self.newRecord:SetActive(IsNewRecord)
  82. local CurMaxScore = ManagerContainer.DataMgr.ExpeditionDataMgr:GetCurScore()
  83. self.scoreNumber.text.text = tostring(CurMaxScore)
  84. end
  85. function UIExpeditionWinView:SetBuffData(buffNode,buffData)
  86. buffNode.buffCard.buffName.text.text = I18N.T(buffData.Name)
  87. CommonUtil.LoadIcon(self, buffData.Icon, function (sprite)
  88. buffNode.buffCard.buffIcon.image.sprite = sprite
  89. end)
  90. buffNode.buffCard.buffDesc.text.text = I18N.T(buffData.Desc)
  91. buffNode:SetActive(true)
  92. self.uiBase:AddButtonEventListener(buffNode.selectNode.button,self, self.OnClickUseBuff,buffData.Id)
  93. end
  94. function UIExpeditionWinView:OnClickUseBuff(btn,params)
  95. local buffId = params[0]
  96. ManagerContainer.DataMgr.ExpeditionDataMgr:SendSelectBuffReq(buffId)
  97. if self.controller:InBattling() then
  98. ManagerContainer.LuaEventMgr:Dispatch(UIEventNames.EID_SHUT_TIMEBATTLE,Enum.UIPageName.UIExpedition,true)
  99. end
  100. self:UIClose()
  101. end
  102. return UIExpeditionWinView