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

253 lines
8.7 KiB
Lua
Raw Normal View History

2021-04-20 13:58:00 +08:00
QinglongSerectTreasureManager = {}
2020-08-19 10:05:01 +08:00
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
2020-08-26 16:15:52 +08:00
this.level = 0
this.hadBuyTreasure = false
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-26 14:04:26 +08:00
if not this.rewardData[v.ActivityId] then
this.rewardData[v.ActivityId] = {}
end
if not this.rewardData[v.ActivityId][v.Level] then
this.rewardData[v.ActivityId][v.Level] = {}
end
this.rewardData[v.ActivityId][v.Level].level = v.Level
this.rewardData[v.ActivityId][v.Level].activityId = v.ActivityId
2020-08-19 10:05:01 +08:00
if v.Integral then
2020-08-26 14:04:26 +08:00
this.rewardData[v.ActivityId][v.Level].needScore = v.Integral[1][2]
2020-08-19 10:05:01 +08:00
else
2020-08-26 14:04:26 +08:00
this.rewardData[v.ActivityId][v.Level].needScore = 0
2020-08-19 10:05:01 +08:00
end
2020-08-26 14:04:26 +08:00
this.rewardData[v.ActivityId][v.Level].state = -2
this.rewardData[v.ActivityId][v.Level].Reward = {}
2020-08-19 10:05:01 +08:00
local temp = {}
2020-08-26 17:08:04 +08:00
this.rewardData[v.ActivityId][v.Level].type = 2
2020-08-19 10:05:01 +08:00
if v.Reward then
for n,m in ipairs(v.Reward) do
table.insert(temp,{ type = 1,item = { m[1] , m[2] } })
end
2020-08-26 17:08:04 +08:00
else
this.rewardData[v.ActivityId][v.Level].type = 1
2020-08-19 10:05:01 +08:00
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-26 14:04:26 +08:00
this.rewardData[v.ActivityId][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-26 14:51:10 +08:00
if not taskData[v.ActivityId] then
taskData[v.ActivityId] = {}
2020-08-19 10:05:01 +08:00
end
2020-08-26 14:51:10 +08:00
if not taskData[v.ActivityId][v.Type] then
taskData[v.ActivityId][v.Type] = {}
end
taskData[v.ActivityId][v.Type][v.Id] = {}
taskData[v.ActivityId][v.Type][v.Id].id = v.Id
taskData[v.ActivityId][v.Type][v.Id].show = v.Show
taskData[v.ActivityId][v.Type][v.Id].taskValue = v.TaskValue
taskData[v.ActivityId][v.Type][v.Id].integral = v.Integral
taskData[v.ActivityId][v.Type][v.Id].jump = v.Jump
taskData[v.ActivityId][v.Type][v.Id].ActivityId = v.ActivityId
2020-08-19 10:05:01 +08:00
end
end
function this.UpdateTreasureState()
local level = this.GetLevel()
2020-08-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
2020-08-26 17:08:04 +08:00
if this.rewardData[activityId] then
for k,v in pairs(this.rewardData[activityId]) do
if level < v.level then
v.state = -2
2020-08-28 11:05:31 +08:00
end
2020-08-26 17:08:04 +08:00
end
local TreasureRewardState = ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.TreasureOfSomeBody)
if TreasureRewardState and TreasureRewardState.mission then
--state -2 未达成 -1 普通和额外全部领取 0未领取 1激活秘宝可以再次领取
for k,v in ipairs(TreasureRewardState.mission) do
if v and level >= v.missionId then
this.rewardData[activityId][v.missionId].state = v.state
end
end
end
2020-08-28 11:05:31 +08:00
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()
2020-08-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
2020-08-26 17:08:04 +08:00
if this.rewardData[activityId] then
for k,v in pairs(this.rewardData[activityId]) do
if level < k or (level >= k and (not this.GetTreasureState()) and v.type == 1) then
2020-08-26 17:08:04 +08:00
v.state = -2
elseif v.state == -2 then
v.state = 0
end
2020-08-22 20:22:30 +08:00
end
end
end
2020-08-19 10:05:01 +08:00
function this.UpdateTrailWeekTime(msg)
2021-05-28 10:33:53 +08:00
-- LogRed("msg.weekTime:"..msg.weekTime)
2020-08-19 10:05:01 +08:00
this.traiWeekTime = msg.weekTime
end
function this.GetTrailWeekTime(msg)
return this.traiWeekTime
end
function this.GetTimeStartToEnd()
2020-08-24 14:00:15 +08:00
local info= ActivityGiftManager.GetActivityTypeInfo(ActivityTypeDef.TreasureOfSomeBody)
2020-08-19 10:05:01 +08:00
if info then
-- --LogGreen("info.startTime:"..info.startTime.." info.endTime:"..info.endTime)
2020-08-19 10:05:01 +08:00
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))
2021-03-02 16:53:12 +08:00
local time = month .. Language[11342] .. day .. Language[10335]
2020-08-19 10:05:01 +08:00
return time
end
function this.GetTreasureState()
return this.hadBuyTreasure
2020-08-19 10:05:01 +08:00
end
function this.GetScore()
return BagManager.GetItemCountById(this.scoreId)
end
function this.SetSingleRewardState(id,state)
2020-08-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
this.rewardData[activityId][id].state = state
2020-08-22 20:22:30 +08:00
LogBlue("SetSingleRewardState:id:"..id.." state:"..state)
2020-08-19 10:05:01 +08:00
end
function this.GetAllRewardData()
local temp ={}
2020-08-26 20:17:37 +08:00
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
return temp
end
2020-08-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
2020-08-26 20:17:37 +08:00
if not this.rewardData[activityId] then
return temp
end
2020-08-26 14:04:26 +08:00
for i, v in pairs(this.rewardData[activityId]) do
if i ~= 0 then
2020-08-19 10:05:01 +08:00
table.insert(temp,v)
end
end
return temp
end
function this.GetRewardData(lv)
2020-08-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
return this.rewardData[activityId][lv]
2020-08-19 10:05:01 +08:00
end
function this.SetLevel(_level)
2020-08-26 16:15:52 +08:00
this.level = _level
2020-08-19 10:05:01 +08:00
end
function this.SetTreasureBuyStatus(hadBuy)
2021-03-12 14:31:53 +08:00
Log("秘宝礼包购买状态:"..hadBuy)
this.hadBuyTreasure = (hadBuy == 1)
end
2020-08-19 10:05:01 +08:00
function this.GetLevel()
2020-08-26 18:29:27 +08:00
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
return 0
end
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
local level = this.rewardData[activityId][LengthOfTable(this.rewardData[activityId])-1].level
if this.level > level then
this.level = level
2020-08-26 17:13:27 +08:00
end
2020-08-26 16:15:52 +08:00
return this.level
2020-08-19 10:05:01 +08:00
end
function this.GetQinglongTaskData(_curtype)
local curtype = _curtype + 1
local temp = TaskManager.GetTypeTaskList(TaskTypeDef.TreasureOfSomeBody)
local task = {}
2020-08-26 20:17:37 +08:00
if ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
for k,v in ipairs(temp) do
if taskData[activityId] and taskData[activityId][curtype] and taskData[activityId][curtype][v.missionId] then
if taskData[activityId][curtype][v.missionId] then
taskData[activityId][curtype][v.missionId].progress = v.progress
taskData[activityId][curtype][v.missionId].state = v.state
table.insert(task, taskData[activityId][curtype][v.missionId])
end
end
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-26 14:04:26 +08:00
local activityId = ActivityGiftManager.GetActivityIdByType(ActivityTypeDef.TreasureOfSomeBody)
for i, v in pairs(this.rewardData[activityId]) do
2020-08-19 10:05:01 +08:00
if i ~= 0 then
if v.state == 0 or (v.state == 1 and state) then
2020-08-19 10:05:01 +08:00
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
2020-08-27 14:53:27 +08:00
function this.GetSerectTreasureTrailSingleRedPot(_type)
if not ActivityGiftManager.GetActivityOpenStatus(ActivityTypeDef.TreasureOfSomeBody) then
return false
end
local task = this.GetQinglongTaskData(_type)
for i, v in pairs(task) do
if v.state == 1 then
return true
end
end
return false
end
2020-08-19 10:05:01 +08:00
return this