123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- ---@class NewVipInfo
- NewVipInfo = class()
- local this = NewVipInfo
-
- this.vipLevel = 0
- this.vipBoughtGifts = {}
- this.allVIPRedPoint = {}
- this.AllPlayerVip = {}
- function this:Init()
- self:RegistMessages()
- self:Reset()
- end
- function this:Reset()
- end
- function this:RegistMessages()
- SL:RegisterLUAEvent(LUA_EVENT_ROLE_LOGIN, self.EnterGame, self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_RECHARGE_ACTION, self.RES_RECHARGE_ACTION, self)
- SL:RegisterLuaNetMsg(LuaMessageIdToClient.RES_PLAYER_ENTER_VIEW_INFO, self.RES_PLAYER_ENTER_VIEW_INFO, self)
- SL:RegisterLUAEvent(LUA_EVENT_CREATE_PLAYER_SUCCESS, self.LUA_EVENT_CREATE_PLAYER_SUCCESS, self)
- end
- function this:RES_RECHARGE_ACTION(_, message)
- if message.type == "8" then
- this.vipLevel = message.data.lv or 0
- self:GetAllRedPoint()
- SL:onLUAEvent(LUA_EVENT_VIP_CHANGE)
- local userid = SL:GetMetaValue("USER_ID")
- if not userid then
- return
- end
- local level_str = ""
- if this.vipLevel > 0 then
- level_str = "v" .. tostring(this.vipLevel)
- end
- self:SetPlayerHeadVipLevel(userid,level_str)
- end
-
- end
- function this:GetAllRedPoint()
- self.allVIPRedPoint = {}
- local allTable = SL:GetConfigTable("cfg_VIP");
- for key, value in pairs(allTable) do
- if value.grade <= self.vipLevel then
- local expackCfg = SL:GetConfig("cfg_VIP_Pack", value.expack)
- local count ,totalCount = InfoManager.countInfo:GetLimitAndTotalCountByKey(expackCfg.Limitedid)
- self.allVIPRedPoint[value.grade] = count>0
- end
- end
- SL:RefreshPanelALLRedStateKmlByCondition("checkVIPRedDot")
- end
- function this:EnterGame()
- -- SL:SendLuaNetMsg(LuaMessageIdToSever.REQ_FirstChargeGift_Info)
- end
- function this:LUA_EVENT_CREATE_PLAYER_SUCCESS(_id,message)
- local uid = tostring(message)
- local userid = SL:GetMetaValue("USER_ID")
- if uid == userid then
- local level_str = ""
- if this.vipLevel > 0 then
- level_str = "v" .. tostring(this.vipLevel)
- end
- self:SetPlayerHeadVipLevel(uid,level_str)
- else
- if this.AllPlayerVip[uid] then
- self:SetPlayerHeadVipLevel(uid,this.AllPlayerVip[uid])
- end
- end
- end
- function this:RES_PLAYER_ENTER_VIEW_INFO(_id,message)
- if not message.vipLv then
- return
- end
- --SL:LogTable(message,true)
- local level_str = ""
- if message.vipLv > 0 then
- level_str = "v" .. tostring(message.vipLv)
- end
- local uid = tostring(message.rid)
- self:SetPlayerHeadVipLevel(uid,level_str)
- end
- function this:SetPlayerHeadVipLevel(id,level_str)
- local is_success = SL:SetHeadVipName(tonumber(id),"Font/Vip_Font",level_str,0,5,-7)
- if is_success then
- this.AllPlayerVip[id] = nil
- else
- this.AllPlayerVip[id] = level_str
- end
- end
|