72 lines
2.2 KiB
Lua
72 lines
2.2 KiB
Lua
SacredTreeManager = {}
|
|
local this = SacredTreeManager
|
|
local treeLevelConfig = ConfigManager.GetConfig(ConfigName.GodHoodTreeLevel)
|
|
local treeSetting = ConfigManager.GetConfig(ConfigName.GodHoodTreeSetting)
|
|
|
|
function this.Initialize()
|
|
this.treeLevel = 0
|
|
this.towerLevel = 160
|
|
|
|
this.treeLevelConfig={}
|
|
this.getGodHoodTreeLevelConfigData()
|
|
|
|
this.treeSettingData={}
|
|
this.getGodHoodTreeSettingData()
|
|
end
|
|
|
|
--当战力变化时
|
|
function this.OnPowerChange()
|
|
local oldPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
local newPower = 0
|
|
|
|
if oldPower ~= newPower and oldPower ~= 0 then
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPower,newValue = newPower})
|
|
end
|
|
end
|
|
|
|
--树等级表数据
|
|
function this.getGodHoodTreeLevelConfigData()
|
|
for i, v in ConfigPairs(treeLevelConfig) do
|
|
this.treeLevelConfig[v.Id] = v.LvupCost
|
|
end
|
|
end
|
|
|
|
--神应属性数据
|
|
function this.getGodHoodTreeSettingData()
|
|
local data = treeSetting[0].PropertyUnlcokLevelForClient
|
|
for i = 1, #data do
|
|
local tempTable = {}
|
|
tempTable.id = data[i][1]
|
|
tempTable.curNum = data[i][2] >= this.towerLevel and this.towerLevel or data[i][2]
|
|
tempTable.allNum = data[i][2]
|
|
table.insert(this.treeSettingData,tempTable)
|
|
end
|
|
end
|
|
|
|
--计算神应等级
|
|
function this.CulAttri()
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local level = 0
|
|
for i = 1, #attriConfig.PropertyUnlcokLevels do
|
|
local num = attriConfig.PropertyUnlcokLevels[i][2]
|
|
if this.towerLevel >= num then
|
|
level = level + 1
|
|
end
|
|
end
|
|
return level.."/"..#attriConfig.PropertyUnlcokLevels
|
|
end
|
|
|
|
--计算开启下一神应等级还需要的层数
|
|
function this.CulNextAttri()
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local numLeft = 0
|
|
for i = 1, #attriConfig.PropertyUnlcokLevels do
|
|
local num = attriConfig.PropertyUnlcokLevels[i][2]
|
|
if this.towerLevel < num then
|
|
numLeft = num - this.towerLevel
|
|
end
|
|
end
|
|
return numLeft
|
|
end
|
|
|
|
return this |