This commit is contained in:
chenxi 2023-05-16 18:56:54 +08:00
parent f7cd1c6094
commit b9023a0a39
2 changed files with 43 additions and 5 deletions

View File

@ -7,6 +7,7 @@ end
function BountyMainUI:ctor()
self.maxCellIdx = 0
self.maxCellNum = 0
self.endTime = DataManager.BountyData:getEndTime()
-- 默认预览第10档奖励
self.previewRewardIndex = 10
end
@ -304,7 +305,7 @@ function BountyMainUI:scrollToIndex(targetIndex)
end
function BountyMainUI:updateTime()
local remainTime = DataManager.BountyData:getRemainTime()
local remainTime = self.endTime - Time:getServerTime()
if remainTime < 0 then
UIManager:closeUnderUI(self)
return self:closeUI()

View File

@ -7,6 +7,10 @@ function BountyData:ctor()
self.data.dirty = false
end
function BountyData:clear()
DataManager:unregisterCrossDayFunc("BountyData")
end
function BountyData:init(data)
data = data or GConst.EMPTY_TABLE
self.season = data.season or 1
@ -18,6 +22,10 @@ function BountyData:init(data)
self.endTime = 0
self:initBountyTime()
self:initBountyLevelCfg()
DataManager:registerCrossDayFunc("BountyData", function()
self:checkNextSeason()
self:markDirty()
end)
end
function BountyData:initBountyTime()
@ -30,7 +38,13 @@ function BountyData:initBountyTime()
end
function BountyData:initBountyLevelCfg()
if self.bountyLevelCfg == nil then
self.bountyLevelCfg = {}
else
for i = 1, #self.bountyLevelCfg do
table.remove(self.bountyLevelCfg)
end
end
local cfg = ConfigManager:getConfig("bounty_level")
for k, v in pairs(cfg) do
if v.season == self.season then
@ -40,6 +54,30 @@ function BountyData:initBountyLevelCfg()
self.repeatLevelInfo = table.remove(self.bountyLevelCfg)
end
function BountyData:checkNextSeason()
if self.endTime > Time:getServerTime() then
return
end
local nextSeason = self.season + 1
local info = ConfigManager:getConfig("bounty_time")[nextSeason]
if info == nil then
self.endTime = 0
return
end
self.endTime = Time:getCertainTimeByStr(info.end_time)
self.season = nextSeason
self.level = 1
self.exp = 0
self.bought = false
for k, v in pairs(self.claimed) do
self.claimed[k] = false
end
for k, v in pairs(self.proClaimed) do
self.proClaimed[k] = false
end
self:initBountyLevelCfg()
end
function BountyData:getBought()
return self.bought
end
@ -157,9 +195,8 @@ function BountyData:markDirty()
self.data.dirty = not self.data.dirty
end
function BountyData:getRemainTime()
local nowTime = Time:getServerTime()
return self.endTime - nowTime
function BountyData:getEndTime()
return self.endTime
end
function BountyData:getExpItemIcon()