UILuckyEggShowCtr.lua 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. local UILuckyEggShowCtr = class("UILuckyEggShowCtr", require("UICtrBase"))
  2. function UILuckyEggShowCtr:Init(view)
  3. self.view = view
  4. end
  5. function UILuckyEggShowCtr:SetData(data)
  6. self.asyncIdx = 0
  7. self.data = data
  8. self:InitData()
  9. end
  10. function UILuckyEggShowCtr:GetAsyncIdx()
  11. self.asyncIdx = self.asyncIdx + 1
  12. return self.asyncIdx
  13. end
  14. function UILuckyEggShowCtr:GetData()
  15. return self.data
  16. end
  17. function UILuckyEggShowCtr:OnDispose()
  18. self.data = nil
  19. self.view = nil
  20. self.curShowIdx = nil
  21. self.showDatas = nil
  22. end
  23. function UILuckyEggShowCtr:InitData()
  24. self.curShowIdx = 1
  25. local LuckyEggData = ManagerContainer.DataMgr.LuckyEggDataMgr:GetLuckyEggData()
  26. local showDatas = {}
  27. if LuckyEggData then
  28. local LuckyEggCfgData = ManagerContainer.CfgMgr:GetLuckyEggCfgByType(LuckyEggData.luckyType)
  29. if LuckyEggCfgData and LuckyEggCfgData.ShowItemType and #LuckyEggCfgData.ShowItemType > 0 then
  30. if LuckyEggData.rewards then
  31. for i = 1, #LuckyEggData.rewards do
  32. local reward = LuckyEggData.rewards[i]
  33. if reward then
  34. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(reward.cfgId)
  35. if CommonUtil.EleInTable(itemCfgData.ResType, LuckyEggCfgData.ShowItemType) then
  36. showDatas[#showDatas + 1] = reward
  37. end
  38. end
  39. end
  40. end
  41. end
  42. end
  43. if #showDatas <= 0 then
  44. self.showDatas = { { cfgId = 1, num = 0 } }
  45. else
  46. self.showDatas = showDatas
  47. end
  48. end
  49. function UILuckyEggShowCtr:GetShowData()
  50. return self.showDatas[self.curShowIdx]
  51. end
  52. function UILuckyEggShowCtr:ChangeNextData()
  53. self.curShowIdx = self.curShowIdx + 1
  54. end
  55. function UILuckyEggShowCtr:CheckMustShow()
  56. for i = self.curShowIdx + 1, #self.showDatas do
  57. local showData = self.showDatas[i]
  58. if showData then
  59. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(showData.cfgId)
  60. if itemCfgData and itemCfgData.Quality >= 4 then
  61. self.curShowIdx = i
  62. return true
  63. end
  64. end
  65. end
  66. return false
  67. end
  68. function UILuckyEggShowCtr:GetCurMustShowComplete()
  69. local showData = self:GetShowData()
  70. if showData then
  71. local itemCfgData = ManagerContainer.CfgMgr:GetItemById(showData.cfgId)
  72. if itemCfgData and itemCfgData.Quality >= 4 then
  73. return true
  74. end
  75. end
  76. return false
  77. end
  78. return UILuckyEggShowCtr