miduo_client/Assets/ManagedResources/~Lua/Modules/SacredTree/SacredTreeManager.lua

185 lines
7.0 KiB
Lua
Raw Normal View History

2020-12-11 16:03:27 +08:00
SacredTreeManager = {}
local this = SacredTreeManager
local treeLevelConfig = ConfigManager.GetConfig(ConfigName.GodHoodTreeLevel)
local treeSetting = ConfigManager.GetConfig(ConfigName.GodHoodTreeSetting)
2020-12-15 17:27:16 +08:00
local jewerLevelUpConfig = ConfigManager.GetConfig(ConfigName.JewelRankupConfig)
local PropertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
local ClientAttriData = ConfigManager.GetConfigData(ConfigName.GodHoodTreeSetting,0).PropertyUnlcokLevelForClient
2020-12-11 16:03:27 +08:00
function this.Initialize()
this.treeLevel = 0
2021-03-10 15:54:42 +08:00
this.SacredtreeLevelConfig={}
2020-12-11 16:03:27 +08:00
this.getGodHoodTreeLevelConfigData()
this.treeSettingData={}
this.getGodHoodTreeSettingData()
end
--当战力变化时
function this.OnPowerChange(oldPower)
local newPower = FormationManager.GetFormationPower(FormationTypeDef.FORMATION_NORMAL)
2020-12-11 16:03:27 +08:00
if oldPower ~= newPower and oldPower ~= 0 then
UIManager.OpenPanel(UIName.WarPowerChangeNotifyPanelV2,{oldValue = oldPower,newValue = newPower})
end
end
2020-12-21 13:43:04 +08:00
function this.GetTowerLevel()
2021-02-22 13:44:03 +08:00
return MonsterCampManager.GetFourElementTotalWave()
2020-12-21 13:43:04 +08:00
end
2020-12-11 16:03:27 +08:00
--树等级表数据
function this.getGodHoodTreeLevelConfigData()
for i, v in ConfigPairs(treeLevelConfig) do
2021-03-10 15:54:42 +08:00
this.SacredtreeLevelConfig[v.Id] = v.LvupCost
2020-12-11 16:03:27 +08:00
end
end
--神应属性数据
function this.getGodHoodTreeSettingData()
2020-12-21 13:43:04 +08:00
local wave = this.GetTowerLevel()
2020-12-11 16:03:27 +08:00
local data = treeSetting[0].PropertyUnlcokLevelForClient
for i = 1, #data do
local tempTable = {}
tempTable.id = data[i][1]
2020-12-21 13:43:04 +08:00
tempTable.curNum = data[i][2] >= wave and wave or data[i][2]
2020-12-11 16:03:27 +08:00
tempTable.allNum = data[i][2]
table.insert(this.treeSettingData,tempTable)
end
end
2021-02-22 18:42:26 +08:00
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
2020-12-11 16:03:27 +08:00
--计算神应等级
2021-08-30 18:09:06 +08:00
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
2020-12-11 16:03:27 +08:00
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
local level = 0
for i = 1, #attriConfig.PropertyUnlcokLevels do
local num = attriConfig.PropertyUnlcokLevels[i][2]
2020-12-21 13:43:04 +08:00
if wave >= num then
2020-12-11 16:03:27 +08:00
level = level + 1
end
end
return level
2020-12-11 16:03:27 +08:00
end
--计算开启下一神应等级还需要的层数
function this.CulNextAttri()
2020-12-21 13:43:04 +08:00
local wave = this.GetTowerLevel()
2020-12-11 16:03:27 +08:00
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
local numLeft = 0
for i = 1, #attriConfig.PropertyUnlcokLevels do
local num = attriConfig.PropertyUnlcokLevels[i][2]
2020-12-21 13:43:04 +08:00
if wave < num then
2020-12-21 20:24:36 +08:00
numLeft = num - wave
2020-12-11 16:03:27 +08:00
end
end
return numLeft
end
2020-12-15 17:27:16 +08:00
--计算开启下一神应等级的层数
function this.NextAttriFloor()
2020-12-21 13:43:04 +08:00
local wave = this.GetTowerLevel()
2020-12-15 17:27:16 +08:00
local attriConfig = ConfigManager.GetConfigDataByKey(ConfigName.GodHoodTreeSetting,"Id",0)
local numLeft = 0
for i = 1, #attriConfig.PropertyUnlcokLevels do
local num = attriConfig.PropertyUnlcokLevels[i][2]
2020-12-21 13:43:04 +08:00
if wave < num then
2020-12-15 17:27:16 +08:00
return num
end
end
2021-08-31 19:03:29 +08:00
return attriConfig.PropertyUnlcokLevels[#attriConfig.PropertyUnlcokLevels][2]
2020-12-15 17:27:16 +08:00
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]
2021-08-30 18:09:06 +08:00
proList[index] = skillValue
-- if info[2] ~= 0 then
-- proList[index] = skillValue
-- end
2020-12-15 17:27:16 +08:00
end
end
end
return proList
end
2021-03-10 15:54:42 +08:00
function this.CheckRedPoint()
2021-09-01 11:49:22 +08:00
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
2021-03-10 15:54:42 +08:00
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
2022-01-08 10:33:31 +08:00
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
2022-01-08 10:33:31 +08:00
data[i].text2 = string.format("<color=%s>+%s",color2,(configNextData.Property[i][2] - configData.Property[i][2])/100).."%</color>"
end
else
data[i].text2 = "<color=#F3D98F>已达上限</color>"
end
-- LogGreen(data[i].text1.." "..data[i].text2)
end
return data
end
2020-12-11 16:03:27 +08:00
return this