2021-01-22 16:53:50 +08:00
|
|
|
|
|
|
|
local propertyConfig = ConfigManager.GetConfig(ConfigName.PropertyConfig)
|
|
|
|
local heroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
|
|
|
HeroPowerManager = {}
|
|
|
|
local this = HeroPowerManager
|
|
|
|
|
|
|
|
--计算战斗力
|
|
|
|
local propToSS = {}
|
|
|
|
local function CalculateWarForce(powerVal)
|
|
|
|
local powerEndVal = 0
|
|
|
|
for i, v in pairs(powerVal) do
|
2021-01-25 18:14:33 +08:00
|
|
|
if v > 0 and i < HeroProType.WarPower then
|
2021-01-22 16:53:50 +08:00
|
|
|
if not propToSS[i] then
|
|
|
|
propToSS[i] = {Style = propertyConfig[i].Style, Score = propertyConfig[i].Score, TargetPropertyId = propertyConfig[i].TargetPropertyId}
|
|
|
|
end
|
|
|
|
-- 计算战斗
|
|
|
|
local power = v * propToSS[i].Score
|
|
|
|
-- 万分比要转为百分比
|
|
|
|
if propToSS[i].Style == 2 then
|
|
|
|
power = power / 100
|
|
|
|
end
|
|
|
|
powerEndVal = powerEndVal + power
|
2021-01-25 18:14:33 +08:00
|
|
|
elseif v > 0 and i >= HeroProType.WarPower then
|
|
|
|
powerEndVal = powerEndVal + v
|
2021-01-22 16:53:50 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return math.floor(powerEndVal)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this.Initialize()
|
|
|
|
this.HeroPowerList = {}
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function this.LateUpdate()
|
|
|
|
if this.IsInitAll and this.coInitPower then
|
|
|
|
-- LogRed("coStatus : "..coroutine.status(this.coInitPower))
|
|
|
|
-- if coroutine.status(this.coInitPower) == "suspended" then
|
|
|
|
-- coroutine.resume(this.coInitPower)
|
|
|
|
-- end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 卸程计算每个人的战斗力
|
|
|
|
function this.CO_InitPower()
|
|
|
|
local heroList = HeroManager.GetAllHeroList()
|
|
|
|
LogRed("co start")
|
|
|
|
for k, v in pairs(heroList) do
|
|
|
|
local power = this.GetHeroPower(v.dynamicId)
|
|
|
|
v.warPower = power
|
|
|
|
LogRed("heroPower : "..v.dynamicId .. "|"..power)
|
|
|
|
-- coroutine.yield()
|
|
|
|
end
|
|
|
|
this.IsInitAll = false
|
|
|
|
this.coInitPower = nil
|
|
|
|
|
|
|
|
LogRed("co end")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 初始化所有人的战斗力
|
|
|
|
function this.InitAllPower()
|
|
|
|
this.IsInitAll = true
|
|
|
|
-- if not this.coInitPower then
|
|
|
|
-- this.coInitPower = coroutine.create(this.CO_InitPower)
|
|
|
|
-- end
|
|
|
|
this.CO_InitPower()
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function this.CalPower(heroData, propList)
|
|
|
|
-- body
|
|
|
|
local config = heroConfig[heroData.tId]
|
|
|
|
local subProp = config.SecondaryFactor
|
|
|
|
if subProp then
|
|
|
|
for i = 1, #subProp do
|
|
|
|
local propType = subProp[i][1]
|
|
|
|
local propValue = subProp[i][2]
|
|
|
|
if propList[propType] then
|
|
|
|
propList[propType] = propList[propType] - propValue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 将百分比加成计算到人物身上
|
|
|
|
for k, v in pairs(propList) do
|
2021-01-25 18:14:33 +08:00
|
|
|
if k < HeroProType.WarPower then
|
|
|
|
if not propToSS[k] then
|
|
|
|
local config = propertyConfig[k]
|
|
|
|
propToSS[k] = {Style = config.Style, Score = config.Score, TargetPropertyId = config.TargetPropertyId}
|
|
|
|
end
|
|
|
|
local tpId = propToSS[k].TargetPropertyId
|
|
|
|
if propList[k] > 0 and tpId > 0 then
|
2021-01-29 15:04:07 +08:00
|
|
|
if k ~= 69 and k ~= 70 then--PVP 增减伤 没有处理
|
|
|
|
if not propList[tpId] then
|
|
|
|
propList[tpId] = 0
|
|
|
|
end
|
|
|
|
propList[tpId] = math.floor( propList[tpId] + propList[tpId] * propList[k] / 10000)
|
|
|
|
end
|
2021-01-25 18:14:33 +08:00
|
|
|
end
|
|
|
|
else
|
|
|
|
propList[k] = v
|
2021-01-22 16:53:50 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
LogPinkTable(propList)
|
|
|
|
|
|
|
|
return CalculateWarForce(propList)
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取英雄战斗力
|
|
|
|
function this.GetHeroPower(dId, formationId)
|
|
|
|
-- 重新计算人物属性
|
|
|
|
local propList = HeroPropManager.GetHeroProp(dId, formationId)
|
|
|
|
--
|
|
|
|
-- 计算战斗力
|
|
|
|
local heroData = HeroManager.CreateHeroCountData(dId)
|
|
|
|
local allPower = this.CalPower(heroData, propList)
|
|
|
|
--
|
|
|
|
if not this.HeroPowerList[dId] then
|
|
|
|
this.HeroPowerList[dId] = {}
|
|
|
|
end
|
|
|
|
this.HeroPowerList[dId].allPower = allPower
|
|
|
|
return this.HeroPowerList[dId].allPower
|
|
|
|
end
|
|
|
|
-- 获取英雄战斗力
|
2021-01-29 15:04:07 +08:00
|
|
|
function this.GetNextHeroPower(dId, formationId,breakId,upStarId)
|
2021-01-22 16:53:50 +08:00
|
|
|
local curHeroData = HeroManager.GetSingleHeroData(dId)
|
2021-01-29 15:04:07 +08:00
|
|
|
local oldBreakId = curHeroData.breakId
|
2021-01-22 16:53:50 +08:00
|
|
|
local oldStarId = curHeroData.upStarId
|
2021-01-29 15:04:07 +08:00
|
|
|
HeroManager.UpdateSingleHeroDatas(dId, curHeroData.lv, curHeroData.star, breakId, upStarId)
|
2021-01-22 16:53:50 +08:00
|
|
|
local curAllPro = HeroPropManager.GetHeroProp(curHeroData.dynamicId,formationId)
|
|
|
|
local curPower = this.GetHeroPower(dId, formationId)
|
2021-01-29 15:04:07 +08:00
|
|
|
HeroManager.UpdateSingleHeroDatas(dId, curHeroData.lv, curHeroData.star, oldBreakId, oldStarId)
|
2021-01-22 16:53:50 +08:00
|
|
|
return curAllPro,curPower
|
|
|
|
end
|
|
|
|
|
|
|
|
-- 通过玩家数据,获取战斗力
|
|
|
|
function this.GetHeroPowerByData(heroData, formationData)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
return HeroPowerManager
|