miduo_client/Assets/ManagedResources/~Lua/Modules/Mission/QinglongSerectTreasureManag...

197 lines
5.9 KiB
Lua
Raw Normal View History

2020-08-19 10:05:01 +08:00
QinglongSerectTreasureManager = {}
local this = QinglongSerectTreasureManager
local TreasureSunlongConfig = ConfigManager.GetConfig(ConfigName.TreasureSunlongConfig)
local TreasureSunLongTaskConfig = ConfigManager.GetConfig(ConfigName.TreasureSunLongTaskConfig)
2020-08-22 20:22:30 +08:00
this.rewardData = {}--表内活动任务数据
2020-08-19 10:05:01 +08:00
local taskData = {}
this.scoreId = 0
this.score = 0
this.traiWeekTime = 0
local level = 0
2020-08-28 11:05:31 +08:00
this.activityId = 0
2020-08-19 10:05:01 +08:00
function this.Initialize()
2020-08-28 11:05:31 +08:00
this.InitializeData()
2020-08-20 17:36:19 +08:00
end
function this.InitializeData()
2020-08-22 20:22:30 +08:00
this.rewardData = {}
2020-08-19 10:05:01 +08:00
taskData = {}
this.scoreId = TreasureSunlongConfig[1].Integral[1][1]
2020-08-28 11:05:31 +08:00
for i, v in ConfigPairs(TreasureSunlongConfig) do
2020-08-22 20:22:30 +08:00
this.rewardData[v.Level] = {}
this.rewardData[v.Level].level = v.Level
this.rewardData[v.Level].activityId = v.ActivityId
2020-08-19 10:05:01 +08:00
if v.Integral then
2020-08-22 20:22:30 +08:00
this.rewardData[v.Level].needScore = v.Integral[1][2]
2020-08-19 10:05:01 +08:00
else
2020-08-22 20:22:30 +08:00
this.rewardData[v.Level].needScore = 0
2020-08-19 10:05:01 +08:00
end
2020-08-22 20:22:30 +08:00
this.rewardData[v.Level].Reward = {}
2020-08-19 10:05:01 +08:00
local temp = {}
if v.Reward then
for n,m in ipairs(v.Reward) do
table.insert(temp,{ type = 1,item = { m[1] , m[2] } })
end
end
if v.TreasureReward then
for n,m in ipairs(v.TreasureReward) do
table.insert(temp,{ type = 2,item = { m[1] , m[2] } })
end
end
2020-08-22 20:22:30 +08:00
this.rewardData[v.Level].Reward = temp
2020-08-19 10:05:01 +08:00
end
2020-08-28 11:05:31 +08:00
for i, v in ConfigPairs(TreasureSunLongTaskConfig) do
2020-08-19 10:05:01 +08:00
if not taskData[v.Type] then
taskData[v.Type] = {}
end
taskData[v.Type][v.Id] = {}
taskData[v.Type][v.Id].id = v.Id
taskData[v.Type][v.Id].show = v.Show
taskData[v.Type][v.Id].taskValue = v.TaskValue
taskData[v.Type][v.Id].integral = v.Integral
taskData[v.Type][v.Id].jump = v.Jump
taskData[v.Type][v.Id].ActivityId = v.ActivityId
end
end
function this.UpdateTreasureState()
local level = this.GetLevel()
2020-08-22 20:22:30 +08:00
for k,v in pairs(this.rewardData) do
if level < k then
2020-08-19 10:05:01 +08:00
v.state = -2
end
end
2020-08-28 11:05:31 +08:00
this.activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
local TreasureRewardState = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.TreasureOfSomeBody)
if TreasureRewardState and TreasureRewardState.mission then
--state -2 未达成 -1 普通和额外全部领取 0未领取 1激活秘宝可以再次领取
2020-08-22 20:22:30 +08:00
for k,v in ipairs(TreasureRewardState.mission) do
2020-08-28 11:05:31 +08:00
if v and level >= v.missionId then
2020-08-22 20:22:30 +08:00
this.rewardData[v.missionId].state = v.state
else
this.rewardData[v.missionId].state = -2
2020-08-28 11:05:31 +08:00
end
end
end
2020-08-19 10:05:01 +08:00
end
2020-08-22 20:22:30 +08:00
function this.UpdateTreasureState2()
local level = this.GetLevel()
for k,v in pairs(this.rewardData) do
if level < k then
v.state = -2
elseif v.state == -2 then
v.state = 0
end
end
end
2020-08-19 10:05:01 +08:00
function this.UpdateTrailWeekTime(msg)
LogRed("msg.weekTime:"..msg.weekTime)
this.traiWeekTime = msg.weekTime
end
function this.GetTrailWeekTime(msg)
return this.traiWeekTime
end
function this.GetTimeStartToEnd()
2020-08-22 22:27:52 +08:00
local info= ActivityGiftManager.GetActivityInfoByType(ActivityTypeDef.TreasureOfSomeBody)
2020-08-19 10:05:01 +08:00
if info then
local startTime= this.GetTimeShow(info.startTime)
local endtime= this.GetTimeShow(info.endTime)
return startTime,endtime,info.endTime
end
end
---时间格式化接口
function this.GetTimeShow(data)
local year = math.floor(os.date("%Y", data))
local month = math.floor(os.date("%m", data))
local day = math.floor(os.date("%d", data))
local time = year .. "" .. month .. "" .. day .. ""
return time
end
function this.GetTreasureState()
this.TreasrueState = OperatingManager.GetGoodsBuyTime(GoodsTypeDef.FindBaby,5001)
return this.TreasrueState
end
function this.GetScore()
return BagManager.GetItemCountById(this.scoreId)
end
function this.SetSingleRewardState(id,state)
2020-08-22 20:22:30 +08:00
this.rewardData[id].state = state
LogBlue("SetSingleRewardState:id:"..id.." state:"..state)
2020-08-19 10:05:01 +08:00
end
function this.GetAllRewardData()
local temp ={}
2020-08-22 20:22:30 +08:00
for i, v in pairs(this.rewardData) do
2020-08-28 11:05:31 +08:00
if i ~= 0 and v.activityId == this.activityId then
2020-08-19 10:05:01 +08:00
table.insert(temp,v)
end
end
return temp
end
function this.GetRewardData(lv)
2020-08-22 20:22:30 +08:00
return this.rewardData[lv]
2020-08-19 10:05:01 +08:00
end
function this.SetLevel(_level)
level = _level
end
function this.GetLevel()
return level
end
function this.GetQinglongTaskData(_curtype)
local curtype = _curtype + 1
local temp = TaskManager.GetTypeTaskList(TaskTypeDef.TreasureOfSomeBody)
local task = {}
for k,v in ipairs(temp) do
2020-08-28 11:05:31 +08:00
if taskData[curtype][v.missionId] and taskData[curtype][v.missionId].ActivityId == this.activityId then
2020-08-19 10:05:01 +08:00
taskData[curtype][v.missionId].progress = v.progress
taskData[curtype][v.missionId].state = v.state
table.insert(task, taskData[curtype][v.missionId])
end
end
2020-08-21 20:11:24 +08:00
-- LogBlue("每周任务个数:"..#task)
2020-08-19 10:05:01 +08:00
return task
end
function this.GetQinglongSerectTreasureRedPot()
2020-08-22 16:49:12 +08:00
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
2020-08-19 14:12:42 +08:00
return false
end
2020-08-19 10:05:01 +08:00
local state = this.GetTreasureState()
2020-08-22 20:22:30 +08:00
for i, v in pairs(this.rewardData) do
2020-08-19 10:05:01 +08:00
if i ~= 0 then
if v.state == 0 or (v.state == 1 and state > 0) then
return true
end
end
end
return false
end
function this.GetSerectTreasureTrailRedPot()
2020-08-22 16:49:12 +08:00
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
2020-08-19 14:12:42 +08:00
return false
end
2020-08-19 10:05:01 +08:00
for i = 1,2 do
local task = this.GetQinglongTaskData(i)
for i, v in pairs(task) do
if v.state == 1 then
return true
end
end
end
return false
end
return this