UINoobPlayerPackInfo.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---
  2. --- Generated by EmmyLua(https://github.com/EmmyLua)
  3. --- Created by admin.
  4. --- DateTime: 2024/11/11 11:02
  5. ---@class UINoobPlayerPackInfo
  6. UINoobPlayerPackInfo = class()
  7. local this = UINoobPlayerPackInfo
  8. function this:ctor()
  9. end
  10. function this:Reset()
  11. end
  12. function this:Init()
  13. self:InitData()
  14. self:RegistMessages()
  15. self.NoobPlayerPackAllData = SL:GetConfigTable("cfg_Starterpack")
  16. self.NoobPlayerPackData = {}
  17. end
  18. function this:InitData()
  19. end
  20. function this:RegistMessages()
  21. SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self)
  22. SL:RegisterLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE, this.LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE, self)
  23. end
  24. --服务器发送礼包组消息后刷新礼包组的数据
  25. function this:RES_RECHARGE_ACTION(_, message)
  26. if tonumber(message.type)~= 9 then --类型9
  27. return
  28. end
  29. self.NoobPlayerPackData = {}
  30. if message then
  31. local itemInfo = {}
  32. local itemCountInfo = {}
  33. local buycount = 0 --剩余次数
  34. local totalcount = 0
  35. for k , v in ipairs(self.NoobPlayerPackAllData) do
  36. if this:IsOpenJudge(v.condition)then
  37. itemInfo = {}
  38. itemInfo.id = v.id
  39. itemInfo.Price = v.Price
  40. itemInfo.Packagename= v.Packagename
  41. itemInfo.conditionid = v.condition
  42. itemInfo.Rewards = v.Rewards
  43. itemInfo.rebate = v.rebate
  44. itemInfo.canBuy = true
  45. itemInfo.RechargeId = 0
  46. itemInfo.Countkey = 0
  47. buycount = 0
  48. totalcount = 0
  49. for key,value in pairs(message.data) do
  50. itemCountInfo = SL:GetConfig('cfg_recharge',tonumber(value))
  51. if itemCountInfo.parameter == v.id then
  52. itemInfo.RechargeId = tonumber(value)
  53. itemInfo.Countkey = itemCountInfo.Countkey
  54. buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(itemCountInfo.Countkey)
  55. if buycount < 1 then
  56. itemInfo.canBuy = false
  57. end
  58. break
  59. end
  60. end
  61. table.insert(self.NoobPlayerPackData,itemInfo)
  62. end
  63. end
  64. end
  65. local isRedPoint = false
  66. for k,v in pairs(self.NoobPlayerPackData) do
  67. if v.Price== 0 and v.canBuy then
  68. isRedPoint = true
  69. end
  70. end
  71. InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NoobPlayer",isRedPoint)
  72. SL:onLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_CHANGE)
  73. end
  74. --Count刷新
  75. function this:LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE()
  76. local isRedPoint = false
  77. local buycount = 0 --剩余次数
  78. local totalcount = 0
  79. for k,v in pairs(self.NoobPlayerPackData) do
  80. buycount = 0
  81. totalcount = 0
  82. v.canBuy = true
  83. buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(v.Countkey)
  84. if buycount < 1 then
  85. v.canBuy = false
  86. end
  87. if v.Price== 0 and v.canBuy then
  88. isRedPoint = true
  89. end
  90. end
  91. InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NoobPlayer",isRedPoint)
  92. SL:onLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_CHANGE)
  93. end
  94. function this:IsOpenJudge(condition)
  95. local isShow = condition == "" or ConditionManager.Check4D(condition)
  96. ---if else 可特殊处理页签显示隐藏
  97. return isShow
  98. end