--- --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by admin. --- DateTime: 2024/11/11 11:02 ---@class UINoobPlayerPackInfo UINoobPlayerPackInfo = class() local this = UINoobPlayerPackInfo function this:ctor() end function this:Reset() end function this:Init() self:InitData() self:RegistMessages() self.NoobPlayerPackAllData = SL:GetConfigTable("cfg_Starterpack") self.NoobPlayerPackData = {} end function this:InitData() end function this:RegistMessages() SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self) SL:RegisterLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE, this.LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE, self) end --服务器发送礼包组消息后刷新礼包组的数据 function this:RES_RECHARGE_ACTION(_, message) if tonumber(message.type)~= 9 then --类型9 return end self.NoobPlayerPackData = {} if message then local itemInfo = {} local itemCountInfo = {} local buycount = 0 --剩余次数 local totalcount = 0 for k , v in ipairs(self.NoobPlayerPackAllData) do if this:IsOpenJudge(v.condition)then itemInfo = {} itemInfo.id = v.id itemInfo.Price = v.Price itemInfo.Packagename= v.Packagename itemInfo.conditionid = v.condition itemInfo.Rewards = v.Rewards itemInfo.rebate = v.rebate itemInfo.canBuy = true itemInfo.RechargeId = 0 itemInfo.Countkey = 0 buycount = 0 totalcount = 0 for key,value in pairs(message.data) do itemCountInfo = SL:GetConfig('cfg_recharge',tonumber(value)) if itemCountInfo.parameter == v.id then itemInfo.RechargeId = tonumber(value) itemInfo.Countkey = itemCountInfo.Countkey buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(itemCountInfo.Countkey) if buycount < 1 then itemInfo.canBuy = false end break end end table.insert(self.NoobPlayerPackData,itemInfo) end end end local isRedPoint = false for k,v in pairs(self.NoobPlayerPackData) do if v.Price== 0 and v.canBuy then isRedPoint = true end end InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NoobPlayer",isRedPoint) SL:onLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_CHANGE) end --Count刷新 function this:LUA_EVENT_NOOBPACK_RECHARGE_COUNT_CHANGE() local isRedPoint = false local buycount = 0 --剩余次数 local totalcount = 0 for k,v in pairs(self.NoobPlayerPackData) do buycount = 0 totalcount = 0 v.canBuy = true buycount,totalcount = InfoManager.countInfo:GetLimitAndTotalCountByKey(v.Countkey) if buycount < 1 then v.canBuy = false end if v.Price== 0 and v.canBuy then isRedPoint = true end end InfoManager.mainRechargeInfo:RefreshMainRechargeRedPoint("tog_NoobPlayer",isRedPoint) SL:onLUAEvent(LUA_EVENT_NOOBPACK_RECHARGE_CHANGE) end function this:IsOpenJudge(condition) local isShow = condition == "" or ConditionManager.Check4D(condition) ---if else 可特殊处理页签显示隐藏 return isShow end