miduo_client/Assets/ManagedResources/~Lua/Modules/TreasureOfHeaven/TreasureOfHeavenManager.lua

92 lines
2.9 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
TreasureOfHeavenManger = {}
2020-06-03 19:09:01 +08:00
local this = TreasureOfHeavenManger
2020-08-27 22:10:08 +08:00
local ConfigData = ConfigManager.GetConfig(ConfigName.WorldBossTreasureConfig)
2020-06-03 19:09:01 +08:00
2020-08-27 22:10:08 +08:00
this.curScore = 0--当前分数
this.resetTime = 0--倒计时
this.rewardStateData = {}--各个任务状态数据
-- local rewardData = {}--表内活动任务数据
2020-07-24 18:30:26 +08:00
this.TreasrueState = nil--礼包购买状态
2020-06-03 19:09:01 +08:00
2020-08-27 22:10:08 +08:00
function this.UpdateData(msg)
-- rewardData = {}
-- for i, v in ConfigPairs(ConfigData) do
-- table.insert(rewardData, v)
-- end
if msg.score then
this.curScore = msg.score
end
if msg.resetTime then
this.resetTime = msg.resetTime
end
if msg.treasureRewardState then
if #msg.treasureRewardState == 1 then
for i = 1, #this.rewardStateData do
if this.rewardStateData[i].id == msg.treasureRewardState.id then
this.rewardStateData[i].state = msg.treasureRewardState.state
end
end
elseif #msg.treasureRewardState > 1 then
this.rewardStateData = msg.treasureRewardState
end
2020-06-03 19:09:01 +08:00
end
2020-07-24 18:30:26 +08:00
this.TreasrueState = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.TreasureOfHeaven,106)
2020-06-03 19:09:01 +08:00
end
function this.SetTreasureState()
2020-07-24 18:30:26 +08:00
this.TreasrueState = 1
return this.TreasrueState
2020-06-03 19:09:01 +08:00
end
function this.SetSingleRewardState(id,state)
2020-08-27 22:10:08 +08:00
for i = 1, #this.rewardStateData do
if(this.rewardStateData[i].id == id)then
this.rewardStateData[i].state = state
2020-06-03 19:09:01 +08:00
end
end
CheckRedPointStatus(RedPointType.Expedition_Treasure)
end
function this.GetAllRewardData()
2020-08-27 22:10:08 +08:00
local data={}
for i = 1, #this.rewardStateData do
for k, v in ConfigPairs(ConfigData) do
if this.rewardStateData[i].id == v.Id then
table.insert(data, v)
end
end
end
return data
2020-06-03 19:09:01 +08:00
end
--红点检测
2020-07-24 18:30:26 +08:00
function this.RedPointState(singleRewardData,TreasrueState)
2020-08-27 22:10:08 +08:00
if this.curScore >= ConfigData[singleRewardData.id].Integral then
2020-07-24 18:30:26 +08:00
if singleRewardData.state==0 and this.TreasrueState==1 or
singleRewardData.state==1 and this.TreasrueState==1 or
singleRewardData.state==0 and this.TreasrueState==0 then
2020-06-03 19:09:01 +08:00
return true
end
return false
end
return false
end
function this.RedPoint()
2020-08-27 22:10:08 +08:00
local data={}
for i, v in ConfigPairs(ConfigData) do
table.insert(data, v)
end
for i =1, #this.rewardStateData do
2020-07-24 18:30:26 +08:00
local curTreasrueState = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.TreasureOfHeaven,106)
2020-08-27 22:10:08 +08:00
if this.curScore >= ConfigData[this.rewardStateData[i].id].Integral then
if this.rewardStateData[i].state==0 and curTreasrueState==1 or
this.rewardStateData[i].state==1 and curTreasrueState==1 or
this.rewardStateData[i].state==0 and curTreasrueState==0 then
2020-06-03 19:09:01 +08:00
return true
end
end
end
return false
end
2020-07-25 20:42:11 +08:00
return this