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

193 lines
5.8 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

QinglongSerectTreasureManager = {}
local this = QinglongSerectTreasureManager
local TreasureSunlongConfig = ConfigManager.GetConfig(ConfigName.TreasureSunlongConfig)
local TreasureSunLongTaskConfig = ConfigManager.GetConfig(ConfigName.TreasureSunLongTaskConfig)
local rewardData = {}--表内活动任务数据
local taskData = {}
this.scoreId = 0
this.score = 0
this.traiWeekTime = 0
local level = 0
function this.Initialize()
end
function this.InitializeData()
rewardData = {}
taskData = {}
this.scoreId = TreasureSunlongConfig[1].Integral[1][1]
local id = ActivityGiftManager.GetActivityIdByType(8)
if not ActivityGiftManager.GetActivityOpenStatus(id) then
return
end
local treasureSunlongConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.TreasureSunlongConfig,"ActivityId",id)
for i, v in ConfigPairs(treasureSunlongConfig) do
rewardData[v.Level] = {}
rewardData[v.Level].level = v.Level
if v.Integral then
rewardData[v.Level].needScore = v.Integral[1][2]
else
rewardData[v.Level].needScore = 0
end
rewardData[v.Level].Reward = {}
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
rewardData[v.Level].Reward = temp
end
local treasureSunlongtaskConfig = ConfigManager.GetAllConfigsDataByKey(ConfigName.TreasureSunLongTaskConfig,"ActivityId",id)
for i, v in ConfigPairs(treasureSunlongtaskConfig) do
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()
for k,v in pairs(rewardData) do
if level > k then
v.state = -2
else
v.state = 0
end
end
local TreasureRewardState = ActivityGiftManager.GetActivityTypeInfo(8)
if TreasureRewardState then
--state -2 未达成 -1 普通和额外全部领取 0未领取 1激活秘宝可以再次领取
if TreasureRewardState.mission then
for k,v in ipairs(TreasureRewardState.mission) do
if level >= v.missionId then
rewardData[v.missionId].state = v.state
else
rewardData[v.missionId].state = -2
end
end
end
end
end
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()
local info= ActivityGiftManager.GetActivityInfoByType(801)
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)
rewardData[id].state = state
end
function this.GetAllRewardData()
local temp ={}
for i, v in pairs(rewardData) do
if i ~= 0 then
table.insert(temp,v)
end
end
return temp
end
function this.GetRewardData(lv)
return rewardData[lv]
end
function this.SetLevel(_level)
level = _level
end
function this.GetLevel()
return level
end
function this.GetQinglongTaskData(_curtype)
local id = ActivityGiftManager.GetActivityIdByType(8)
local curtype = _curtype + 1
local temp = TaskManager.GetTypeTaskList(TaskTypeDef.TreasureOfSomeBody)
local task = {}
for k,v in ipairs(temp) do
if taskData[curtype][v.missionId] and taskData[curtype][v.missionId].ActivityId == id then
taskData[curtype][v.missionId].progress = v.progress
taskData[curtype][v.missionId].state = v.state
table.insert(task, taskData[curtype][v.missionId])
end
end
LogBlue("每周任务个数:"..#task)
return task
end
function this.GetQinglongSerectTreasureRedPot()
local id =ActivityGiftManager.GetActivityIdByType(8)
if not ActivityGiftManager.GetActivityOpenStatus(id) then
return false
end
local state = this.GetTreasureState()
for i, v in pairs(rewardData) do
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()
local id =ActivityGiftManager.GetActivityIdByType(8)
if not ActivityGiftManager.GetActivityOpenStatus(id) then
return false
end
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