118 lines
3.5 KiB
Lua
118 lines
3.5 KiB
Lua
SacredTreeManager = {}
|
|
local this = SacredTreeManager
|
|
local treeLevelConfig = ConfigManager.GetConfig(ConfigName.GodHoodTreeLevel)
|
|
local treeSetting = ConfigManager.GetConfig(ConfigName.GodHoodTreeSetting)
|
|
local jewerLevelUpConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig)
|
|
|
|
function this.Initialize()
|
|
this.treeLevel = 0
|
|
|
|
this.treeLevelConfig={}
|
|
this.getGodHoodTreeLevelConfigData()
|
|
|
|
this.treeSettingData={}
|
|
this.getGodHoodTreeSettingData()
|
|
end
|
|
|
|
--当战力变化时
|
|
function this.OnPowerChange(oldPower)
|
|
local newPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
|
|
if oldPower ~= newPower and oldPower ~= 0 then
|
|
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPower,newValue = newPower})
|
|
end
|
|
end
|
|
|
|
function this.GetTowerLevel()
|
|
return MonsterCampManager.GetFourElementTotalWave()
|
|
end
|
|
|
|
--树等级表数据
|
|
function this.getGodHoodTreeLevelConfigData()
|
|
for i, v in ConfigPairs(treeLevelConfig) do
|
|
this.treeLevelConfig[v.Id] = v.LvupCost
|
|
end
|
|
end
|
|
|
|
--神应属性数据
|
|
function this.getGodHoodTreeSettingData()
|
|
local wave = this.GetTowerLevel()
|
|
local data = treeSetting[0].PropertyUnlcokLevelForClient
|
|
for i = 1, #data do
|
|
local tempTable = {}
|
|
tempTable.id = data[i][1]
|
|
tempTable.curNum = data[i][2] >= wave and wave or data[i][2]
|
|
tempTable.allNum = data[i][2]
|
|
table.insert(this.treeSettingData,tempTable)
|
|
end
|
|
end
|
|
|
|
--计算神应等级
|
|
function this.CulAttri()
|
|
local wave = this.GetTowerLevel()
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local level = 0
|
|
for i = 1, #attriConfig.PropertyUnlcokLevels do
|
|
local num = attriConfig.PropertyUnlcokLevels[i][2]
|
|
if wave >= num then
|
|
level = level + 1
|
|
end
|
|
end
|
|
return level
|
|
end
|
|
|
|
--计算开启下一神应等级还需要的层数
|
|
function this.CulNextAttri()
|
|
local wave = this.GetTowerLevel()
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local numLeft = 0
|
|
for i = 1, #attriConfig.PropertyUnlcokLevels do
|
|
local num = attriConfig.PropertyUnlcokLevels[i][2]
|
|
if wave < num then
|
|
numLeft = num - this.GetTowerLevel()
|
|
end
|
|
end
|
|
return numLeft
|
|
end
|
|
|
|
--计算开启下一神应等级的层数
|
|
function this.NextAttriFloor()
|
|
local wave = this.GetTowerLevel()
|
|
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
|
|
local numLeft = 0
|
|
for i = 1, #attriConfig.PropertyUnlcokLevels do
|
|
local num = attriConfig.PropertyUnlcokLevels[i][2]
|
|
if wave < num then
|
|
return num
|
|
end
|
|
end
|
|
end
|
|
|
|
--获取当前等级加成的属性
|
|
function this.GetCurLvPropertyValue(_type, _id, _lv)
|
|
local lvConfig = nil
|
|
--获取当前等级属性加成
|
|
for _, configInfo in ConfigPairs(jewerLevelUpConfig) do
|
|
if configInfo.Type == _type and configInfo.PoolID == _id and configInfo.Level == _lv then
|
|
lvConfig = configInfo
|
|
break
|
|
end
|
|
end
|
|
local proList = {}
|
|
if lvConfig then
|
|
for i = 1, table.getn(lvConfig.Property) do
|
|
local info = lvConfig.Property[i]
|
|
if info then
|
|
local index = info[1]
|
|
local skillValue = {}
|
|
skillValue.currValue = info[2]
|
|
if info[2] ~= 0 then
|
|
proList[index] = skillValue
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return proList
|
|
end
|
|
|
|
return this |