sk-client/Assets/ManagedResources/~Lua/Modules/FormationCenter/FormationCenterManager.lua

80 lines
2.3 KiB
Lua

FormationCenterManager = {}
local this = FormationCenterManager
local investigateLevelUpFailTimes = 1--启明星累计失败次数
local investigateLevel = 0--启明星等级
local storeTypeId = 0--解锁商品类型
local investigateConfigs = ConfigManager.GetConfig(ConfigName.InvestigateConfig)
function this.Initialize()
end
--初始化数据
function this.InitData(msg)
investigateLevelUpFailTimes = msg.investigateLevelUpFailTimes
--and msg.investigateLevel > 0 or 1
if msg.investigateLevel and msg.investigateLevel > 0 then
investigateLevel = msg.investigateLevel
else
if ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.InvestigateCenter) then
investigateLevel = 1
end
end
if investigateLevel > 0 then
storeTypeId = investigateConfigs[investigateLevel].StoreTypeId
end
end
--获取商品ID
function this.GetStoreId()
return storeTypeId
end
--启明星是否开启
function this.IsOpen()
return investigateLevel > 0
end
--获取启明星等级
function this.GetInvestigateLevel()
return investigateLevel
end
function this.GetFailTimes()
return investigateLevelUpFailTimes
end
--设置启明星等级
function this.SetInvestigateLevel(msg, func)
investigateLevel = msg.level
investigateLevelUpFailTimes = msg.failTimes
if investigateLevel > 0 then
storeTypeId = investigateConfigs[investigateLevel].StoreTypeId
end
-- storeTypeId = msg.storeTypeId
if func then
func()
end
Game.GlobalEvent:DispatchEvent(GameEvent.FormationCenter.OnFormationCenterLevelChange, msg.level)
end
--获取加成属性
function this.GetAllPropertyAdd()
if investigateLevel == 0 or not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.InvestigateCenter) then -- not ActTimeCtrlManager.SingleFuncState(FUNCTION_OPEN_TYPE.InvestigateCenter) or
return {}
end
local addAllProVal = {}
local investigateConfig = investigateConfigs[investigateLevel]
for i = 1, #investigateConfig.PropertyAdd do
local propertyId = investigateConfig.PropertyAdd[i][1]
local propertyValue = investigateConfig.PropertyAdd[i][2]
if addAllProVal[propertyId] == nil then
addAllProVal[propertyId] = 0
end
addAllProVal[propertyId] = addAllProVal[propertyId] + propertyValue
end
return addAllProVal
end
return this