【自动恢复物品】物品恢复机制改为前端计算
parent
56898d9c26
commit
0e19f21805
|
|
@ -26,7 +26,11 @@ local _TimeCheckFunc = {
|
||||||
if curCount < maxCount then
|
if curCount < maxCount then
|
||||||
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.AdventureAlianInvasionTicket].nextFlushTime
|
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.AdventureAlianInvasionTicket].nextFlushTime
|
||||||
local remationTime = nextFreshTime - PlayerManager.serverTime
|
local remationTime = nextFreshTime - PlayerManager.serverTime
|
||||||
return remationTime
|
if remationTime >= 0 then
|
||||||
|
return remationTime
|
||||||
|
end
|
||||||
|
-- 需要刷新数量
|
||||||
|
return -2
|
||||||
else -- 数量已满返回 -1
|
else -- 数量已满返回 -1
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
@ -37,7 +41,11 @@ local _TimeCheckFunc = {
|
||||||
if curCount < maxCount then
|
if curCount < maxCount then
|
||||||
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.ActPower].nextFlushTime
|
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.ActPower].nextFlushTime
|
||||||
local remationTime = nextFreshTime - PlayerManager.serverTime
|
local remationTime = nextFreshTime - PlayerManager.serverTime
|
||||||
return remationTime
|
if remationTime > 0 then
|
||||||
|
return remationTime
|
||||||
|
end
|
||||||
|
-- 需要刷新数量
|
||||||
|
return -2
|
||||||
else -- 数量已满返回 -1
|
else -- 数量已满返回 -1
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
@ -78,8 +86,30 @@ local _TimeCheckFunc = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
local GameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1)
|
||||||
function this.Initialize()
|
function this.Initialize()
|
||||||
|
Timer.New(function()
|
||||||
|
for _, data in ipairs(GameSetting.ItemAdd) do
|
||||||
|
local itemId = data[1]
|
||||||
|
local deltaNum = data[2]
|
||||||
|
local deltaTime = data[3]
|
||||||
|
if this.IsAutoRecover(itemId) then
|
||||||
|
local leftTime = this.GetRecoverTime(itemId)
|
||||||
|
-- 已满不需要刷新
|
||||||
|
if leftTime == -1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
--
|
||||||
|
if leftTime == -2 then
|
||||||
|
BagManager.bagDatas[itemId].num = BagManager.bagDatas[itemId].num + deltaNum
|
||||||
|
BagManager.bagDatas[itemId].nextFlushTime = BagManager.bagDatas[itemId].nextFlushTime + deltaTime
|
||||||
|
|
||||||
|
LogPink("自动恢复物品数量刷新:"..itemId.."|"..BagManager.bagDatas[itemId].num.."|"..BagManager.bagDatas[itemId].nextFlushTime)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end, 1, -1, true):Start()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 获取道具是否自动恢复
|
-- 获取道具是否自动恢复
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue