857 lines
26 KiB
Lua
857 lines
26 KiB
Lua
|
||
------------------------------------------------
|
||
--作者: 王圣
|
||
--日期: 2019-12-16
|
||
--文件: VipSystem.lua
|
||
--模块: VipSystem
|
||
--描述: vip系统
|
||
------------------------------------------------
|
||
--引用
|
||
local BaseData = require "Logic.VipSystem.VipBaseData"
|
||
local TimeUtils = CS.Thousandto.Core.Base.TimeUtils;
|
||
local VipSystem = {
|
||
--前一vip等级
|
||
PrevLevel = -1,
|
||
--最大vip等级
|
||
MaxVip = 0,
|
||
--最小vip等级
|
||
MinVip = 0,
|
||
--升级前的vip等级
|
||
PreLevel = 0,
|
||
--是否领取了今天的礼包
|
||
IsRewardDaily = false,
|
||
|
||
DicVipData = nil,
|
||
|
||
|
||
--是否显示累计充值红点
|
||
IsShowRechargeRedPoint = false,
|
||
--累充金额
|
||
CurRecharge = 0,
|
||
--累计充值数据 {Cfg , State : 0 可领取 1 不可领取 2 已领取}
|
||
ListRechargeData = List:New(),
|
||
--修神锻体数据 {Cfg, IsShow, IsShowBtn, State}
|
||
ListDuanTiData = List:New(),
|
||
|
||
--是否已经领取了免费vip经验
|
||
IsGetFreeVipExp = nil,
|
||
--免费vip打开的任务id
|
||
FreeVIPTaskList = List:New(),
|
||
--宝珠状态
|
||
BaoZhuState = -1,
|
||
BaoZhuLeftTime = 0,
|
||
}
|
||
|
||
function VipSystem:Initialize()
|
||
--初始化累计充值数据 和修神锻体数据
|
||
self.ListRechargeData:Clear()
|
||
self.ListDuanTiData:Clear()
|
||
DataConfig.DataVIPTrueRecharge:Foreach(function(k, v)
|
||
if v.Type == 1 then
|
||
local data = {Cfg = v, State = 1}
|
||
self.ListRechargeData:Add(data)
|
||
elseif v.Type == 2 then
|
||
local data = {Cfg = v, IsShow = false, State = 1}
|
||
self.ListDuanTiData:Add(data)
|
||
end
|
||
end)
|
||
self.TimerEventId = GameCenter.TimerEventSystem:AddTimeStampDayEvent(2, 2,
|
||
true, nil, function(id, remainTime, param)
|
||
--跨天了
|
||
self.IsRewardDaily = false
|
||
self:CheckRedPoint()
|
||
end)
|
||
local _gCfg = DataConfig.DataGlobal[GlobalName.FreeVIP_AutoOpen_Task]
|
||
if _gCfg ~= nil then
|
||
local _ids = Utils.SplitNumber(_gCfg.Params, '_')
|
||
if _ids ~= nil and #_ids > 0 then
|
||
for i = 1, #_ids do
|
||
self.FreeVIPTaskList:Add(_ids[i])
|
||
end
|
||
end
|
||
end
|
||
GameCenter.RegFixEventHandle(LogicEventDefine.EVENT_COIN_CHANGE_UPDATE, self.CoinChange, self)
|
||
GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_TASKFINISH, self.OnTaskFinish, self)
|
||
end
|
||
|
||
function VipSystem:UnInitialize()
|
||
GameCenter.UnRegFixEventHandle(LogicEventDefine.EVENT_COIN_CHANGE_UPDATE, self.CoinChange, self)
|
||
GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_TASKFINISH, self.OnTaskFinish, self)
|
||
end
|
||
|
||
function VipSystem:GetVipDic()
|
||
if self.DicVipData == nil then
|
||
local index = 0
|
||
self.DicVipData = Dictionary:New()
|
||
DataConfig.DataVip:Foreach(function(k, v)
|
||
if index == 0 then
|
||
self.MinVip = k
|
||
end
|
||
local data = BaseData:New(v)
|
||
data:ParseCfg(v)
|
||
self.DicVipData:Add(k,data)
|
||
index = index + 1
|
||
self.MaxVip = k
|
||
end)
|
||
end
|
||
return self.DicVipData
|
||
end
|
||
|
||
--获取玩家vip等级
|
||
function VipSystem:GetVipLevel()
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
return lp.VipLevel
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取玩家vip经验
|
||
function VipSystem:GetVipExp()
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
return lp.VipExp
|
||
end
|
||
return 0
|
||
end
|
||
|
||
function VipSystem:GetVipData(lv)
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(lv) then
|
||
return _dic[lv]
|
||
end
|
||
return nil
|
||
end
|
||
|
||
--获取传入的vip等级升级需要的经验
|
||
function VipSystem:GetLvExp(lv)
|
||
if lv<self.MaxVip then
|
||
local cfg = DataConfig.DataVip[lv+1]
|
||
if cfg ~= nil then
|
||
return cfg.VipLevelUp
|
||
end
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取等级礼包
|
||
function VipSystem:GetLvItems(lv)
|
||
local _dic = self:GetVipDic()
|
||
local data = _dic[lv]
|
||
if data ~= nil then
|
||
return data.ListLiBao
|
||
end
|
||
return nil
|
||
end
|
||
|
||
--获取每日礼包
|
||
function VipSystem:GetDailyItems(lv)
|
||
local _dic = self:GetVipDic()
|
||
local data = _dic[lv]
|
||
if data ~= nil then
|
||
return data.ListDayLiBao
|
||
end
|
||
return nil
|
||
end
|
||
|
||
--通过货币id获取资源id
|
||
function VipSystem:GetCoinIconId(coinId)
|
||
local cfg = DataConfig.DataItem[coinId]
|
||
if cfg == nil then
|
||
return 0
|
||
end
|
||
return cfg.Icon
|
||
end
|
||
|
||
--获取原价
|
||
function VipSystem:GetOriginPriceTab(lv)
|
||
local ret = nil
|
||
local _dic = self:GetVipDic()
|
||
local data = _dic[lv]
|
||
if data ~= nil then
|
||
local list = Utils.SplitStr(data.Cfg.VipRewardPriceOriginal,'_')
|
||
ret = {ItemId = tonumber(list[1]), Price = tonumber(list[2])}
|
||
end
|
||
return ret
|
||
end
|
||
|
||
--获取现价
|
||
function VipSystem:GetCurPriceTab(lv)
|
||
local ret = nil
|
||
local _dic = self:GetVipDic()
|
||
local data = _dic[lv]
|
||
if data ~= nil then
|
||
local list = Utils.SplitStr(data.Cfg.VipRewardPriceNow,'_')
|
||
ret = {ItemId = tonumber(list[1]), Price = tonumber(list[2])}
|
||
end
|
||
return ret
|
||
end
|
||
|
||
function VipSystem:GetVipLevel()
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
--设置vip经验
|
||
return lp.VipLevel
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取vip特权参数
|
||
function VipSystem:GetCurVipPowerParam(id)
|
||
local lv = self:GetVipLevel()
|
||
if lv == 0 then
|
||
return 0
|
||
end
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(lv) then
|
||
local data = _dic[lv]
|
||
return data:GetPowerParam(id)
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取下一级vip特权参数
|
||
function VipSystem:GetVipPowerParamByLv(lv,id)
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(lv) then
|
||
local data = _dic[lv]
|
||
return data:GetPowerParam(id)
|
||
end
|
||
return 0
|
||
end
|
||
|
||
--获取vip特权描述
|
||
function VipSystem:GetCurVipPowerDes(id)
|
||
local des = ""
|
||
local poweId = 0
|
||
local lv = self:GetVipLevel()
|
||
if lv == 0 then
|
||
return des
|
||
end
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(lv) then
|
||
local data = _dic[lv]
|
||
if data:HavePrivilege(id) then
|
||
local param = data:GetPowerParam(id)
|
||
local powerCfg = DataConfig.DataVipPower[id]
|
||
if powerCfg ~= nil then
|
||
des = UIUtils.CSFormat( DataConfig.DataMessageString.Get("C_VIP_chuandao_show_word"),param )
|
||
end
|
||
end
|
||
end
|
||
return des
|
||
end
|
||
|
||
function VipSystem:GetVipPowerDes(lv,id)
|
||
local des = ""
|
||
local poweId = 0
|
||
if lv == 0 then
|
||
return des
|
||
end
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(lv) then
|
||
local data = _dic[lv]
|
||
if data:HavePrivilege(id) then
|
||
local param = data:GetPowerParam(id)
|
||
local powerCfg = DataConfig.DataVipPower[id]
|
||
if powerCfg ~= nil then
|
||
des = UIUtils.CSFormat( DataConfig.DataMessageString.Get("C_VIP_chuandao_show_word"), param )
|
||
end
|
||
end
|
||
end
|
||
return des
|
||
end
|
||
|
||
--当前vip是否有某个特权
|
||
function VipSystem:IsHavePrivilegeID(id)
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp == nil then
|
||
return false
|
||
end
|
||
local _curBaseData = self:GetVipData(lp.VipLevel)
|
||
if _curBaseData == nil then
|
||
return false
|
||
end
|
||
return _curBaseData:HavePrivilege(id)
|
||
end
|
||
|
||
--根据副本ID获取特权ID
|
||
function VipSystem:GetPowerIDByCopyMap(copyId)
|
||
if copyId == 5201 then
|
||
--天界之门
|
||
return 22
|
||
elseif copyId == 6001 then
|
||
--凌云妖塔
|
||
return 13
|
||
elseif copyId == 6002 then
|
||
--心魔环境
|
||
return 14
|
||
elseif copyId == 6003 then
|
||
--锁灵台
|
||
return 15
|
||
else
|
||
return -1
|
||
end
|
||
end
|
||
|
||
--根据副本id获取合并次数权限id
|
||
function VipSystem:GetMegrePowerIDByCopyMap(copyId)
|
||
if copyId == 6001 then
|
||
--凌云妖塔
|
||
return 33
|
||
elseif copyId == 6002 then
|
||
--心魔环境
|
||
return 32
|
||
elseif copyId == 6003 then
|
||
--锁灵台
|
||
return 31
|
||
else
|
||
return -1
|
||
end
|
||
end
|
||
|
||
--根据boss副本ID获取特权ID
|
||
function VipSystem:GetPowerIDByBossId(bossId)
|
||
--世界Boss
|
||
if bossId == MapLogicTypeDefine.WorldBossCopy then
|
||
return 16
|
||
--套装Boss
|
||
elseif bossId == MapLogicTypeDefine.SuitGemCopy then
|
||
return 17
|
||
--宝石Boss
|
||
elseif bossId == MapLogicTypeDefine.SuitGemCopy then
|
||
return 18
|
||
--境界Boss
|
||
elseif bossId == MapLogicTypeDefine.StatureBossCopy then
|
||
return 20
|
||
else
|
||
return - 1
|
||
end
|
||
end
|
||
|
||
--获取升级后增加的特权
|
||
function VipSystem:GetAddPrivilege()
|
||
local privilegeList = List:New()
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
local cfg = DataConfig.DataVip[lp.VipLevel]
|
||
if cfg ~= nil then
|
||
local list = Utils.SplitStr(cfg.VipUpPower,';')
|
||
if list ~= nil then
|
||
for i = 1,#list do
|
||
local values = Utils.SplitStr(list[i],'_')
|
||
if values ~= nil then
|
||
local id = tonumber(values[1])
|
||
local param = tonumber(values[2])
|
||
local powerCfg = DataConfig.DataVipPower[id]
|
||
if powerCfg ~= nil then
|
||
local des = nil
|
||
if param ~= 0 then
|
||
des = UIUtils.CSFormat( powerCfg.VipLevelUpDescribe,param )
|
||
else
|
||
des = powerCfg.VipLevelUpDescribe
|
||
end
|
||
privilegeList:Add(des)
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
end
|
||
return privilegeList
|
||
end
|
||
|
||
--获取修神锻体当前已领取的配置表id
|
||
function VipSystem:GetCurTrueVipCfgId()
|
||
local id = 0
|
||
for i = 1,#self.ListDuanTiData do
|
||
if self.ListDuanTiData[i].State == 2 then
|
||
id = self.ListDuanTiData[i].Cfg.Id
|
||
end
|
||
end
|
||
return id
|
||
end
|
||
|
||
|
||
function VipSystem:Update(dt)
|
||
if not self.IsGetFreeVipExp and self.WaitAutoOpenFreeVip and self:CanAutoOpenFreeVip() then
|
||
GameCenter.PushFixEvent(UIEventDefine.UIFreeVIPForm_OPEN)
|
||
self.WaitAutoOpenFreeVip = false
|
||
end
|
||
end
|
||
|
||
function VipSystem:CoinChange(obj, sender)
|
||
if obj > 0 and obj == ItemTypeCode.VipExp then
|
||
local exp = GameCenter.ItemContianerSystem:GetEconomyWithType(ItemTypeCode.VipExp)
|
||
self:ResVipExpChange(exp)
|
||
end
|
||
end
|
||
|
||
function VipSystem:OnTaskFinish(obj, sender)
|
||
if self.IsGetFreeVipExp == false and self.FreeVIPTaskList:Contains(obj) then
|
||
self:TryAutoOpenFreeVipForm()
|
||
end
|
||
end
|
||
|
||
--尝试打开免费VIP界面,在可以打开的时候再打开
|
||
function VipSystem:TryAutoOpenFreeVipForm()
|
||
self.WaitAutoOpenFreeVip = true
|
||
end
|
||
|
||
--是否可以自动打开免费VIP界面,在野图非引导模式下可以打开
|
||
function VipSystem:CanAutoOpenFreeVip()
|
||
local _mapCfg = GameCenter.MapLogicSystem.MapCfg
|
||
if _mapCfg == nil then
|
||
return false
|
||
end
|
||
if _mapCfg.Type == 5 or _mapCfg.Type == 2 then
|
||
return false
|
||
end
|
||
if GameCenter.BlockingUpPromptSystem:IsRunning() then
|
||
return false
|
||
end
|
||
return true
|
||
end
|
||
|
||
--vip经验变化
|
||
function VipSystem:ResVipExpChange(exp)
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
--设置vip经验
|
||
local prevLv = 0
|
||
local curLv = 0
|
||
DataConfig.DataVip:Foreach(function(k, v)
|
||
if lp.VipExp >= v.VipLevelUp then
|
||
prevLv = k
|
||
end
|
||
if exp >= v.VipLevelUp then
|
||
curLv = k
|
||
end
|
||
end)
|
||
--检测是否升级
|
||
if prevLv < curLv then
|
||
--玩家vip等级发生变化了 弹出vip 升级界面
|
||
lp.VipLevel = curLv
|
||
GameCenter.PushFixEvent(UILuaEventDefine.UIVipLvForm_CLOSE)
|
||
GameCenter.PushFixEvent(UILuaEventDefine.UIVipLvForm_OPEN)
|
||
end
|
||
lp.VipExp = exp
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPFORM_UPDATE)
|
||
end
|
||
end
|
||
|
||
--检查vip红点
|
||
function VipSystem:CheckRedPoint()
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.Vip, not self.IsRewardDaily and self:GetVipLevel() > 0 and self.BaoZhuState ~= 0)
|
||
end
|
||
|
||
--获取显示珠宝剩余时间
|
||
function VipSystem:GetZhuBaoLeftTime()
|
||
local _ret = 0
|
||
_ret = self.BaoZhuLeftTime - GameCenter.HeartSystem.ServerTime
|
||
return _ret
|
||
end
|
||
|
||
--宝珠是否开启,包括限时和非限时宝珠
|
||
function VipSystem:BaoZhuIsOpen()
|
||
return self.BaoZhuState ~= 0
|
||
end
|
||
-------------------------msg-----------------------
|
||
|
||
--请求vip
|
||
function VipSystem:ReqVip()
|
||
GameCenter.Network.Send("MSG_Vip.ReqVip")
|
||
end
|
||
|
||
--请求vip领奖
|
||
function VipSystem:ReqVipReward()
|
||
self.PreLevel = self:GetVipLevel()
|
||
GameCenter.Network.Send("MSG_Vip.ReqVipReward")
|
||
end
|
||
|
||
--请求购买等级礼包
|
||
function VipSystem:ReqVipPurGift(vipLv)
|
||
GameCenter.Network.Send("MSG_Vip.ReqVipPurGift", {lv = vipLv})
|
||
end
|
||
|
||
--请求累充奖励
|
||
function VipSystem:ReqVipRechargeReward(rewardId)
|
||
GameCenter.Network.Send("MSG_Vip.ReqVipRechargeReward", {id = rewardId})
|
||
end
|
||
|
||
--请求激活宝珠
|
||
function VipSystem:ReqActiveVipPearl(t)
|
||
GameCenter.Network.Send("MSG_Vip.ReqActiveVipPearl", {id = t})
|
||
end
|
||
|
||
--登录红点
|
||
function VipSystem:ResVipRed(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
local _oldGet = self.IsGetFreeVipExp
|
||
self.IsGetFreeVipExp = result.isGetFreeAward
|
||
self.IsRewardDaily = not result.isRed
|
||
if _oldGet ~= self.IsGetFreeVipExp then
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_FREEVIP_GETSTATE_CHANGED)
|
||
end
|
||
self:CheckRedPoint()
|
||
end
|
||
|
||
--等级列表信息
|
||
function VipSystem:ResVip(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
self.IsRewardDaily = result.isGet
|
||
local mask = 1
|
||
local _dic = self:GetVipDic()
|
||
local listKey = _dic:GetKeys()
|
||
for i = 1,#listKey do
|
||
mask = 1<<listKey[i]-1
|
||
if result.hasGet & mask > 0 then
|
||
_dic[listKey[i]].IsBuy = true
|
||
else
|
||
_dic[listKey[i]].IsBuy = false
|
||
end
|
||
end
|
||
--设置vip等级
|
||
local lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if lp ~= nil then
|
||
--设置vip经验
|
||
self.CurLevel = lp.VipLevel
|
||
end
|
||
self:CheckRedPoint()
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPFORM_UPDATE)
|
||
end
|
||
|
||
--每日礼包返回
|
||
function VipSystem:ResVipReward(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
--每日礼包购买成功
|
||
self.IsRewardDaily = true
|
||
local level = self:GetVipLevel()
|
||
local data = self:GetVipData(level)
|
||
if data ~= nil then
|
||
local itemList = List:New()
|
||
for i = 1,#data.ListDayLiBao do
|
||
local item = {Id = data.ListDayLiBao[i].Id, Num = data.ListDayLiBao[i].Num, IsBind = data.ListDayLiBao[i].Bind }
|
||
itemList:Add(item)
|
||
end
|
||
GameCenter.PushFixEvent(UIEventDefine.UIWelfareGetItemForm_OPEN, itemList)
|
||
end
|
||
self:CheckRedPoint()
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPFORM_BUY_RESULT)
|
||
end
|
||
|
||
--等级礼包购买返回
|
||
function VipSystem:ResVipPurGift(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
--等级礼包购买成功
|
||
local _dic = self:GetVipDic()
|
||
if _dic:ContainsKey(result.lv) then
|
||
local data = _dic[result.lv]
|
||
data.IsBuy = true
|
||
local itemList = List:New()
|
||
for i = 1,#data.ListLiBao do
|
||
local item = {Id = data.ListLiBao[i].Id, Num = data.ListLiBao[i].Num, IsBind = data.ListLiBao[i].Bind }
|
||
itemList:Add(item)
|
||
end
|
||
GameCenter.PushFixEvent(UIEventDefine.UIWelfareGetItemForm_OPEN, itemList)
|
||
end
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPFORM_BUY_RESULT)
|
||
end
|
||
|
||
--累计充值金额
|
||
function VipSystem:ResVipRechageMoney(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
local showRdPoint = false
|
||
self.CurRecharge = result.money
|
||
GameCenter.PaySystem:ResVipRechageMoney(self.CurRecharge)
|
||
local _lp = GameCenter.GameSceneSystem:GetLocalPlayer()
|
||
if _lp ~= nil then
|
||
_lp.PropMoudle.CurRecharge = self.CurRecharge
|
||
end
|
||
local _addGet = true
|
||
for i = 1,#self.ListRechargeData do
|
||
--先设置是否可以领取状态
|
||
if self.CurRecharge>= self.ListRechargeData[i].Cfg.RechargeLimit then
|
||
--判断是否领取过了
|
||
if self.ListRechargeData[i].State ~= 2 then
|
||
self.ListRechargeData[i].State = 0
|
||
end
|
||
else
|
||
self.ListRechargeData[i].State = 1
|
||
end
|
||
if not showRdPoint and self.ListRechargeData[i].State == 0 then
|
||
showRdPoint = true
|
||
end
|
||
|
||
if self.ListRechargeData[i].State ~= 2 then
|
||
--只要有不是已领取的,关掉累充功能
|
||
_addGet = false
|
||
end
|
||
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipRecharge, not _addGet)
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipRecharge,showRdPoint)
|
||
end
|
||
|
||
local isShow = false
|
||
local showRewardId = -1
|
||
local haveRedPoint = false
|
||
for i = 1,#self.ListDuanTiData do
|
||
--先设置是否可以领取状态
|
||
if self.CurRecharge>= self.ListDuanTiData[i].Cfg.RechargeLimit then
|
||
--状态设置为可领取状态
|
||
if self.ListDuanTiData[i].State ~= 2 then
|
||
self.ListDuanTiData[i].State = 0
|
||
end
|
||
else
|
||
self.ListDuanTiData[i].State = 1
|
||
end
|
||
if self.ListDuanTiData[i].State == 2 or self.ListDuanTiData[i].State == 0 then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
if showRewardId == -1 then
|
||
self.ListDuanTiData[i].IsShow = true
|
||
self.ListDuanTiData[i].IsShowBtn = true
|
||
showRewardId = i
|
||
else
|
||
if not isShow then
|
||
self.ListDuanTiData[i].IsShowBtn = false
|
||
self.ListDuanTiData[i].IsShow = true
|
||
isShow = true
|
||
end
|
||
end
|
||
else
|
||
self.ListDuanTiData[i].IsShow = true
|
||
end
|
||
else
|
||
if not isShow then
|
||
self.ListDuanTiData[i].IsShow = true
|
||
isShow = true
|
||
else
|
||
self.ListDuanTiData[i].IsShow = false
|
||
end
|
||
end
|
||
if not haveRedPoint then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
haveRedPoint = true
|
||
end
|
||
end
|
||
end
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipLianTi,haveRedPoint)
|
||
--更新界面
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPRECHARGE_UPDATE)
|
||
--同步一下周常红点
|
||
GameCenter.ZhouChangSystem:UpdateRedPoint()
|
||
end
|
||
|
||
--已领取累计充值列表(包括修神,注意修神需要前面领取了才可以领取后面的)
|
||
function VipSystem:ResVipRechageRewardList(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
local mask = 0
|
||
local showRdPoint = false
|
||
local _addGet = true
|
||
for i = 1,#self.ListRechargeData do
|
||
--先设置是否可以领取状态
|
||
if self.CurRecharge>= self.ListRechargeData[i].Cfg.RechargeLimit then
|
||
--状态设置为可领取状态
|
||
self.ListRechargeData[i].State = 0
|
||
else
|
||
self.ListRechargeData[i].State = 1
|
||
end
|
||
--在通过服务器消息设置是否领取了
|
||
mask = 1<<self.ListRechargeData[i].Cfg.Id-1
|
||
if result.hasGet & mask > 0 then
|
||
self.ListRechargeData[i].State = 2
|
||
end
|
||
if not showRdPoint and self.ListRechargeData[i].State == 0 then
|
||
showRdPoint = true
|
||
end
|
||
|
||
if self.ListRechargeData[i].State ~= 2 then
|
||
--只要有不是已领取的,关掉累充功能
|
||
_addGet = false
|
||
end
|
||
end
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipRecharge, not _addGet)
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipRecharge,showRdPoint)
|
||
|
||
|
||
local isShow = false
|
||
local showRewardId = -1
|
||
local haveRedPoint = false
|
||
for i = 1,#self.ListDuanTiData do
|
||
--先设置是否可以领取状态
|
||
if self.CurRecharge>= self.ListDuanTiData[i].Cfg.RechargeLimit then
|
||
--状态设置为可领取状态
|
||
self.ListDuanTiData[i].State = 0
|
||
else
|
||
self.ListDuanTiData[i].State = 1
|
||
end
|
||
--在通过服务器消息设置是否领取了
|
||
mask = 1<<self.ListDuanTiData[i].Cfg.Id-1
|
||
if result.hasGet & mask > 0 then
|
||
self.ListDuanTiData[i].State = 2
|
||
end
|
||
--如果领取了
|
||
if self.ListDuanTiData[i].State == 2 or self.ListDuanTiData[i].State == 0 then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
if showRewardId == -1 then
|
||
self.ListDuanTiData[i].IsShow = true
|
||
self.ListDuanTiData[i].IsShowBtn = true
|
||
showRewardId = i
|
||
else
|
||
if not isShow then
|
||
self.ListDuanTiData[i].IsShowBtn = false
|
||
self.ListDuanTiData[i].IsShow = true
|
||
isShow = true
|
||
else
|
||
self.ListDuanTiData[i].IsShow = false
|
||
end
|
||
end
|
||
else
|
||
self.ListDuanTiData[i].IsShow = true
|
||
end
|
||
else
|
||
if not isShow then
|
||
self.ListDuanTiData[i].IsShow = true
|
||
isShow = true
|
||
else
|
||
self.ListDuanTiData[i].IsShow = false
|
||
end
|
||
end
|
||
if not haveRedPoint then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
haveRedPoint = true
|
||
end
|
||
end
|
||
end
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipLianTi,haveRedPoint)
|
||
end
|
||
|
||
--累计充值返回
|
||
function VipSystem:ResVipRechargeReward(result)
|
||
if result == nil then
|
||
return
|
||
end
|
||
local _addGet = true
|
||
local showRdPoint = false
|
||
for i = 1,#self.ListRechargeData do
|
||
if self.ListRechargeData[i].Cfg.Id == result.id then
|
||
self.ListRechargeData[i].State = 2
|
||
end
|
||
if not showRdPoint and self.ListRechargeData[i].State == 0 then
|
||
showRdPoint = true
|
||
end
|
||
|
||
if self.ListRechargeData[i].State ~= 2 then
|
||
--只要有不是已领取的,关掉累充功能
|
||
_addGet = false
|
||
end
|
||
end
|
||
if _addGet and GameCenter.MainFunctionSystem:FunctionIsVisible(FunctionStartIdCode.VipRecharge) then
|
||
Utils.ShowMsgBoxAndBtn(function(code)
|
||
GameCenter.PushFixEvent(UIEventDefine.UIVipRechargeForm_Close)
|
||
end, "VIPSYSTEM_TISHI_2", "VIPSYSTEM_TISHI_1")
|
||
end
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipRecharge, not _addGet)
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipRecharge,showRdPoint)
|
||
local isShow = false
|
||
local showRewardId = -1
|
||
local haveRedPoint = false
|
||
for i = 1,#self.ListDuanTiData do
|
||
if self.ListDuanTiData[i].Cfg.Id == result.id then
|
||
self.ListDuanTiData[i].State = 2
|
||
end
|
||
--如果领取了
|
||
if self.ListDuanTiData[i].State == 2 or self.ListDuanTiData[i].State == 0 then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
if showRewardId == -1 then
|
||
self.ListDuanTiData[i].IsShowBtn = true
|
||
showRewardId = i
|
||
end
|
||
end
|
||
self.ListDuanTiData[i].IsShow = true
|
||
else
|
||
if not isShow then
|
||
self.ListDuanTiData[i].IsShowBtn = false
|
||
self.ListDuanTiData[i].IsShow = true
|
||
isShow = true
|
||
else
|
||
self.ListDuanTiData[i].IsShow = false
|
||
end
|
||
end
|
||
if not haveRedPoint then
|
||
if self.ListDuanTiData[i].State == 0 then
|
||
haveRedPoint = true
|
||
end
|
||
end
|
||
end
|
||
|
||
GameCenter.MainFunctionSystem:SetAlertFlag(FunctionStartIdCode.VipLianTi,haveRedPoint)
|
||
--发送消息更新界面
|
||
GameCenter.PushFixEvent(LogicLuaEventDefine.EID_EVENT_VIPRECHARGE_UPDATE)
|
||
end
|
||
|
||
function VipSystem:ResSpecialVipStateInfo(msg)
|
||
if msg == nil then
|
||
return
|
||
end
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationZunGui, false)
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationNormal, false)
|
||
local _isTiShi = false
|
||
local _isShowFunc = false
|
||
local _normal = msg.normalVip
|
||
local _high = msg.highVip
|
||
if _high ~= nil then
|
||
if _high.isActivate then
|
||
if not _high.isNotifyClient then
|
||
--弹出提示
|
||
_isTiShi = true
|
||
GameCenter.PushFixEvent(UILuaEventDefine.UIVipInvationForm_OPEN, 2)
|
||
end
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationZunGui, true)
|
||
_isShowFunc = true
|
||
else
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationZunGui, false)
|
||
end
|
||
end
|
||
if not _isTiShi then
|
||
if _normal.isActivate then
|
||
if not _normal.isNotifyClient then
|
||
--弹出提示
|
||
_isTiShi = true
|
||
GameCenter.PushFixEvent(UILuaEventDefine.UIVipInvationForm_OPEN, 1)
|
||
end
|
||
if not _isShowFunc then
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationNormal, true)
|
||
end
|
||
else
|
||
GameCenter.MainFunctionSystem:SetFunctionVisible(FunctionStartIdCode.VipInvationNormal, false)
|
||
end
|
||
end
|
||
end
|
||
|
||
function VipSystem:ResVipPearlInfo(msg)
|
||
if msg == nil then
|
||
return msg
|
||
end
|
||
self.BaoZhuState = msg.state
|
||
self.BaoZhuLeftTime = msg.deadLine
|
||
if msg.isActive then
|
||
GameCenter.MainFunctionSystem:DoFunctionCallBack(FunctionStartIdCode.Vip)
|
||
GameCenter.MsgPromptSystem:ShowPrompt(DataConfig.DataMessageString.Get("VIP_Powe_Sucs_Notice"))
|
||
end
|
||
end
|
||
|
||
return VipSystem
|