miduo_client/Assets/ManagedResources/~Lua/Modules/Hero/HeroTempPropManager.lua

158 lines
4.8 KiB
Lua

-- debug用
local IsDebug = false
local emptyFunc = function()end
Log_Prop = IsDebug and Log or emptyFunc
LogRed_Prop = IsDebug and LogRed or emptyFunc
LogBlue_Prop = IsDebug and LogBlue or emptyFunc
LogGreen_Prop = IsDebug and LogGreen or emptyFunc
LogPink_Prop = IsDebug and LogPink or emptyFunc
LogRedTable_Prop = IsDebug and LogRedTable or emptyFunc
LogBlueTable_Prop = IsDebug and LogBlueTable or emptyFunc
LogGreenTable_Prop = IsDebug and LogGreenTable or emptyFunc
LogPinkTable_Prop = IsDebug and LogPinkTable or emptyFunc
--
require("Modules.Hero.PropHero")
require("Modules.Hero.PropFunc")
require("Modules.Hero.PropCondition")
HeroTempPropManager = {}
local this = HeroTempPropManager
-- 合并属性列表
local function DoubleTableCompound(allProVal, addProVal)
if addProVal and LengthOfTable(addProVal) > 0 then
for k, v in pairs(addProVal) do
if v > 0 then
if allProVal[k] then
allProVal[k] = allProVal[k] + v
else
allProVal[k] = v
end
end
end
end
end
function this.Initialize()
end
-- 根据heroData获取人物属性
function this.GetHeroProp(heroData, formationData)
local allPropList = {}
-- 获取基础属性
local basePropList, conPropList, teamPropList, conTeamPropList, dePropList = this.GetBaseProp(heroData)
Log_Prop("基础属性")
LogGreenTable_Prop(basePropList)
DoubleTableCompound(allPropList, basePropList)
--
Log_Prop("自身条件属性")
LogGreenTable_Prop(conPropList)
DoubleTableCompound(allPropList, conPropList)
-- 计算减益属性
Log_Prop("减益属性")
this.CountDeProp(dePropList, allPropList)
-- 团队属性加成
Log_Prop("团队属性")
LogGreenTable_Prop(teamPropList)
DoubleTableCompound(allPropList, teamPropList)
-- 团队条件属性加成
Log_Prop("团队条件属性")
LogGreenTable_Prop(conTeamPropList)
DoubleTableCompound(allPropList, conTeamPropList)
Log_Prop("总属性")
LogGreenTable_Prop(allPropList)
return allPropList
end
---=================== 基础属性======================================
-- 获取基础属性
function this.GetBaseProp(heroData)
local basePropList = {}
local conPropList = {}
local teamPropList = {}
local conTeamPropList = {}
local dePropList = {}
for _, powerType in pairs(Hero_Prop_Type) do
LogGreen_Prop(_)
--
-- 判断该类型数据是否需要刷新
if Hero_Prop_Func[powerType] then
-- 计算属性
local propList, conList, tPropList, conTeamList, deProps = Hero_Prop_Func[powerType](heroData)
if propList then
DoubleTableCompound(basePropList, propList)
end
LogPink_Prop("base")
LogPinkTable_Prop(propList)
-- 条件属性
if conList then
LogPink_Prop("con")
for _, cond in ipairs(conList) do
if Condition_Prop_Func[cond.type] then
local propList = Condition_Prop_Func[cond.type](heroData, heroData, cond.propList, cond.args)
DoubleTableCompound(conPropList, propList)
LogPinkTable_Prop(propList)
end
end
end
-- 对编队中其他人的数据
if teamPropList then
DoubleTableCompound(teamPropList, tPropList)
LogPink_Prop("team")
LogPinkTable_Prop(tPropList)
end
-- 对编队中其他人的数据
if conTeamList then
LogPink_Prop("conteam")
for _, cond in ipairs(conTeamList) do
if Condition_Prop_Func[cond.type] then
local propList = Condition_Prop_Func[cond.type](heroData, heroData, cond.propList, cond.args)
DoubleTableCompound(conTeamPropList, propList)
LogPinkTable_Prop(propList)
end
end
end
-- 减益属性
if dePropList then
for _, deProp in ipairs(deProps) do
table.insert(dePropList, deProp)
end
LogPink_Prop("deprop")
LogPinkTable_Prop(deProps)
end
end
end
return basePropList, conPropList, teamPropList, conTeamPropList, dePropList
end
-- 计算减益
function this.CountDeProp(dePropList, allPropList)
if dePropList then
for _, prop in ipairs(dePropList) do
local id = prop.propId
local v = prop.value
LogGreenTable_Prop(string.format("%s|%s", id, v))
allPropList[id] = allPropList[id] * (1 - v / 10000)
end
end
end
return HeroPropManager