224 lines
8.8 KiB
Lua
224 lines
8.8 KiB
Lua
SacredTreeManager = {}
|
|
local this = SacredTreeManager
|
|
local treeLevelConfig = ConfigManager.GetConfig(ConfigName.GodHoodTreeLevel)
|
|
local treeSetting = ConfigManager.GetConfig(ConfigName.GodHoodTreeSetting)
|
|
local jewerLevelUpConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig)
|
|
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
local ClientAttriData = ConfigManager.GetConfigData(ConfigName.GodHoodTreeSetting,0).PropertyUnlcokLevelForClient
|
|
|
|
function this.Initialize()
|
|
this.treeLevel = 0
|
|
|
|
this.SacredtreeLevelConfig={}
|
|
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.SacredtreeLevelConfig[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.GetUnLockNewProperty(trailWaves)
|
|
local data = treeSetting[0].PropertyUnlcokLevelForClient
|
|
for i = 1, #data do
|
|
local tempTable = {}
|
|
if data[i][2] == trailWaves then
|
|
return data[i][1]
|
|
elseif data[i][2] > trailWaves then
|
|
return 0
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
--计算神应等级
|
|
function this.CulAttri(dadta)
|
|
local wave
|
|
if not dadta or EquipTreasureManager.GetSingleTreasureByIdDyn(dadta.idDyn) then
|
|
wave = this.GetTowerLevel()
|
|
else
|
|
wave = dadta.fourTotal or 0
|
|
end
|
|
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 - wave
|
|
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
|
|
return attriConfig.PropertyUnlcokLevels[#attriConfig.PropertyUnlcokLevels][2]
|
|
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]
|
|
proList[index] = skillValue
|
|
-- if info[2] ~= 0 then
|
|
-- proList[index] = skillValue
|
|
-- end
|
|
end
|
|
end
|
|
end
|
|
|
|
return proList
|
|
end
|
|
|
|
function this.CheckRedPoint()
|
|
-- if treeLevelConfig[this.treeLevel].LvupCost and #treeLevelConfig[this.treeLevel].LvupCost > 0 then
|
|
-- local needId = treeLevelConfig[this.treeLevel].LvupCost[1]
|
|
-- local needCost = treeLevelConfig[this.treeLevel].LvupCost[2]
|
|
-- return BagManager.GetTotalItemNum(needId) > needCost
|
|
-- else
|
|
-- return false
|
|
-- end
|
|
end
|
|
|
|
--获取当前等级和下一级的数据
|
|
function this.GetAttriDetail(index)
|
|
local data = {}
|
|
local maxSacredLevel = ConfigManager.GetConfigDataByKey(ConfigName.JewelConfig,"GodHoodPool",index).GodHoodMaxlv
|
|
local level = this.treeLevel < maxSacredLevel and this.treeLevel or maxSacredLevel
|
|
local configData = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",3,"Level",level,"PoolID",index)
|
|
local configNextData = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",3,"Level",level+1,"PoolID",index)
|
|
if this.treeLevel >= maxSacredLevel then--如果当前神树等级超出魂灵宝所能达到的最大等级就取最大
|
|
configNextData = nil
|
|
end
|
|
-- LogRed("#configData.Property:"..tostring(#configData.Property))
|
|
for i = 1, #configData.Property do
|
|
data[i] = {}
|
|
local bool = MonsterCampManager.GetFourElementTotalWave() >= ClientAttriData[i][2]
|
|
local color1 = bool and "#F3D98F" or "#A0A0A0"--是否解锁了当前属性
|
|
local color2 = bool and "#00FF00" or "#A0A0A0"--是否解锁了当前属性
|
|
if PropertyConfig[configData.Property[i][1]].Style == 1 then
|
|
data[i].text1 = string.format("<color=%s>%s+%s</color>",color1,PropertyConfig[configData.Property[i][1]].Info,configData.Property[i][2])
|
|
elseif PropertyConfig[configData.Property[i][1]].Style == 2 then
|
|
data[i].text1 = string.format("<color=%s>%s+%s",color1,PropertyConfig[configData.Property[i][1]].Info,configData.Property[i][2]/100).."%</color>"
|
|
end
|
|
-- LogPink("configNextData:"..tostring(configNextData))
|
|
if configNextData then
|
|
if PropertyConfig[configNextData.Property[i][1]].Style == 1 then
|
|
data[i].text2 = string.format("<color=%s>+%s</color>",color2,configNextData.Property[i][2] - configData.Property[i][2])
|
|
elseif PropertyConfig[configNextData.Property[i][1]].Style == 2 then
|
|
data[i].text2 = string.format("<color=%s>+%s",color2,(configNextData.Property[i][2] - configData.Property[i][2])/100).."%</color>"
|
|
end
|
|
else
|
|
local color = not bool and "A0A0A0" or "F3D98F"
|
|
data[i].text2 = string.format("<color=#%s>已达上限</color>",color)
|
|
end
|
|
-- LogGreen(data[i].text1.." "..data[i].text2)
|
|
end
|
|
return data
|
|
end
|
|
|
|
--获取当前等级和下一级的数据
|
|
function this.GetPropText(_treeLv,_id)
|
|
local data = {}
|
|
local jewerConfig=ConfigManager.GetConfigData(ConfigName.JewelConfig,_id)
|
|
local maxSacredLevel = jewerConfig.GodHoodMaxlv
|
|
local index= jewerConfig.GodHoodPool
|
|
--local maxSacredLevel = ConfigManager.GetConfigDataByKey(ConfigName.JewelConfig,"GodHoodPool",index).GodHoodMaxlv
|
|
local level = _treeLv
|
|
local configData = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",3,"Level",level,"PoolID",index)
|
|
local configNextData = ConfigManager.TryGetConfigDataByThreeKey(ConfigName.JewelRankupConfig,"Type",3,"Level",level+1,"PoolID",index)
|
|
if _treeLv >= maxSacredLevel then--如果当前神树等级超出魂灵宝所能达到的最大等级就取最大
|
|
configNextData = nil
|
|
end
|
|
for i = 1, #configData.Property do
|
|
local bool = MonsterCampManager.GetFourElementTotalWave() >= ClientAttriData[i][2]
|
|
if bool then
|
|
local propArr=configData.Property[i]
|
|
local propId=propArr[1]
|
|
data[propId] = {}
|
|
data[propId].currValue = propArr[2]
|
|
if configNextData then
|
|
local nextPropArr=configNextData.Property[i]
|
|
data[propId].nextValue = nextPropArr[2]
|
|
else
|
|
local color = not bool and "A0A0A0" or "F3D98F"
|
|
data[propId].nextValue = string.format("<color=#%s>已达上限</color>",color)
|
|
end
|
|
end
|
|
end
|
|
local propertyData = {}
|
|
for i = 1, #ClientAttriData do
|
|
if data[ClientAttriData[i][1]] then
|
|
propertyData[ClientAttriData[i][1]]=data[ClientAttriData[i][1]]
|
|
end
|
|
end
|
|
return propertyData
|
|
end
|
|
return this |