UIParterGotView.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. local UIParterGotView = require("UIPOPGot/UIParterGotView_Generate")
  2. local IconItemCtr = require("Common/IconItemCtr")
  3. function UIParterGotView:OnAwake(data)
  4. self.controller = require("UIPOPGot/UIParterGotCtr"):new()
  5. self.controller:Init(self)
  6. self.controller:SetData(data)
  7. end
  8. function UIParterGotView:AddEventListener()
  9. end
  10. function UIParterGotView: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 UIParterGotView:Init()
  21. local datas = self.controller:GetData()
  22. local length = #datas
  23. for i = 1, 10 do
  24. local status = i <= length
  25. self["itemRoot"..i]:SetActive(status)
  26. if status then
  27. local data = datas[i]
  28. local item = self["item"..i].gameObject
  29. if i >= length then
  30. item.animation:Play()
  31. local animationState = item.animation.this:get("GotItemScaleIn")
  32. animationState.speed = 1
  33. elseif i >= length - 1 then
  34. item.animation:Play()
  35. local animationState = item.animation.this:get("GotItemScaleIn")
  36. animationState.speed = 2
  37. end
  38. local itemItem = self["iconItem"..i].gameObject
  39. local itemLua = CommonUtil.BindGridViewItem2Lua(self, itemItem.name, itemItem)
  40. local heroData = ManagerContainer.CfgMgr:GetPartnerDataById(data.cfgId)
  41. local data1 = {cfgId = data.cfgId, num = 1}
  42. IconItemCtr:SetData(self, itemLua, data1, Enum.ItemIEnterType.Partner)
  43. self["itemName"..i].text.text = I18N.T(heroData.Name)
  44. end
  45. end
  46. end
  47. function UIParterGotView:RemoveEventListener()
  48. ManagerContainer.LuaEventMgr:Unregister(self.uiData.name)
  49. end
  50. function UIParterGotView:AddUIEventListener()
  51. ManagerContainer.LuaEventMgr:RegisterUIEvent(self.uiData.name)
  52. self.uiBase:AddButtonEventListener(self.alpha.button, function()
  53. self:UIClose()
  54. end)
  55. end
  56. function UIParterGotView:OnHide()
  57. end
  58. function UIParterGotView:OnShow(data)
  59. self.controller:SetData(data)
  60. self:Init()
  61. end
  62. function UIParterGotView:OnClose()
  63. ManagerContainer.PopGotMgr:PageViewKeep(false)
  64. end
  65. function UIParterGotView:OnDispose()
  66. end
  67. return UIParterGotView