miduo_client/Assets/ManagedResources/~Lua/Modules/Player/AutoRecoverManager.lua

87 lines
3.3 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.

AutoRecoverManager = {}
local this = AutoRecoverManager
--- 注册物品及其获取恢复时间的方法
local _TimeCheckFunc = {
[UpViewRechargeType.EliteCarbonTicket] = function()
local ownNumber = BagManager.GetItemCountById(UpViewRechargeType.EliteCarbonTicket)
if ownNumber < CarbonManager.gameSetting[1].HeroTimes then
return CarbonManager.remainTime
else -- 数量已满返回 -1
return -1
end
end,
-- [UpViewRechargeType.MonsterCampTicket] = function()
-- if MonsterCampManager.IsNeedSupply() then
-- local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.MonsterCampTicket].nextFlushTime
-- local remationTime = nextFreshTime - PlayerManager.serverTime
-- return remationTime
-- else -- 数量已满返回 -1
-- return -1
-- end
-- end,
[UpViewRechargeType.AdventureAlianInvasionTicket] = function()
local curCount = BagManager.GetItemCountById(UpViewRechargeType.AdventureAlianInvasionTicket)
local maxCount = PrivilegeManager.GetPrivilegeNumber(9)
if curCount < maxCount then
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.AdventureAlianInvasionTicket].nextFlushTime
local remationTime = nextFreshTime - PlayerManager.serverTime
return remationTime
else -- 数量已满返回 -1
return -1
end
end,
[UpViewRechargeType.ActPower] = function()
local curCount = EndLessMapManager.GetLeftMapEnergy()
local maxCount = PrivilegeManager.GetPrivilegeNumber(20)
if curCount < maxCount then
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.ActPower].nextFlushTime
local remationTime = nextFreshTime - PlayerManager.serverTime
return remationTime
else -- 数量已满返回 -1
return -1
end
end,
[UpViewRechargeType.Energy] = function()
local curCount = BagManager.GetItemCountById(UpViewRechargeType.Energy)
local maxCount = PlayerManager.userLevelData[PlayerManager.level].MaxEnergy
if curCount < maxCount then
local nextFreshTime = BagManager.bagDatas[UpViewRechargeType.Energy].nextFlushTime
local remationTime = nextFreshTime - PlayerManager.serverTime -- 下一次刷新的时间
-- 计算从下一次刷新到恢复满得时间
local gameSetting = ConfigManager.GetConfigData(ConfigName.GameSetting, 1)
local recoverNum = gameSetting.EnergyRecoverSpeed[1]
local recoverTime = gameSetting.EnergyRecoverSpeed[2]
local fullTime = math.floor((maxCount - curCount) / recoverNum - 1) * recoverTime * 60
return remationTime + fullTime
else -- 数量已满返回 -1
return -1
end
end,
}
function this.Initialize()
end
-- 获取道具是否自动恢复
function AutoRecoverManager.IsAutoRecover(itemId)
if not _TimeCheckFunc[itemId] then
return false
end
return true
end
-- 获取道具恢复时间
function AutoRecoverManager.GetRecoverTime(itemId)
if not _TimeCheckFunc[itemId] then
assert(false, "找到获取恢复时间的方法物品id = ".. itemId)
end
return _TimeCheckFunc[itemId]()
end
return this