2020-05-09 13:31:21 +08:00
|
|
|
|
BattleManager = {}
|
|
|
|
|
local this = BattleManager
|
|
|
|
|
local PassiveSkillLogicConfig = ConfigManager.GetConfig(ConfigName.PassiveSkillLogicConfig)
|
|
|
|
|
local SkillLogicConfig = ConfigManager.GetConfig(ConfigName.SkillLogicConfig)
|
|
|
|
|
local HeroConfig = ConfigManager.GetConfig(ConfigName.HeroConfig)
|
|
|
|
|
local MonsterGroup = ConfigManager.GetConfig(ConfigName.MonsterGroup)
|
|
|
|
|
local MonsterConfig = ConfigManager.GetConfig(ConfigName.MonsterConfig)
|
|
|
|
|
local CombatControl = ConfigManager.GetConfig(ConfigName.CombatControl)
|
|
|
|
|
|
|
|
|
|
local function pairsByKeys(t)
|
|
|
|
|
local a = {}
|
|
|
|
|
for n in pairs(t) do
|
|
|
|
|
if n then
|
|
|
|
|
a[#a+1] = n
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
table.sort(a, function( op1, op2 )
|
|
|
|
|
local type1, type2 = type(op1), type(op2)
|
|
|
|
|
local num1, num2 = tonumber(op1), tonumber(op2)
|
|
|
|
|
|
|
|
|
|
if ( num1 ~= nil) and (num2 ~= nil) then
|
|
|
|
|
return num1 < num2
|
|
|
|
|
elseif type1 ~= type2 then
|
|
|
|
|
return type1 < type2
|
|
|
|
|
elseif type1 == "string" then
|
|
|
|
|
return op1 < op2
|
|
|
|
|
elseif type1 == "boolean" then
|
|
|
|
|
return op1
|
|
|
|
|
-- 以上处理: number, string, boolean
|
|
|
|
|
else -- 处理剩下的: function, table, thread, userdata
|
|
|
|
|
return tostring(op1) < tostring(op2) -- tostring后比较字符串
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
local i = 0
|
|
|
|
|
return function()
|
|
|
|
|
i = i + 1
|
|
|
|
|
return a[i], t[a[i]]
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.PrintBattleTable(tb)
|
|
|
|
|
local indent_str = "\n{"
|
|
|
|
|
local count = 0
|
|
|
|
|
for k,v in pairs(tb) do
|
|
|
|
|
count = count + 1
|
|
|
|
|
end
|
|
|
|
|
for k=1, #tb do
|
|
|
|
|
local v = tb[k]
|
|
|
|
|
if type(v) == "table" then
|
|
|
|
|
indent_str = indent_str .. this.PrintBattleTable(v)
|
2020-06-12 18:04:22 +08:00
|
|
|
|
elseif type(v) == "string" then
|
|
|
|
|
indent_str = indent_str .. "\""..tostring(v) .. "\""
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
indent_str = indent_str .. tostring(v)
|
|
|
|
|
end
|
|
|
|
|
if k < count then
|
|
|
|
|
indent_str = indent_str..","
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local index = 0
|
|
|
|
|
for k,v in pairsByKeys(tb) do
|
|
|
|
|
index = index + 1
|
|
|
|
|
if type(k) ~= "number" then
|
|
|
|
|
if type(v) == "table" then
|
|
|
|
|
indent_str = string.format("%s%s=%s", indent_str, tostring(k), this.PrintBattleTable(v))
|
2020-06-12 18:04:22 +08:00
|
|
|
|
elseif type(v) == "string" then
|
|
|
|
|
indent_str = string.format("%s%s=\"%s\"", indent_str, tostring(k), tostring(v))
|
2020-05-09 13:31:21 +08:00
|
|
|
|
else
|
|
|
|
|
indent_str = string.format("%s%s=%s", indent_str, tostring(k), tostring(v))
|
|
|
|
|
end
|
|
|
|
|
if index < count then
|
|
|
|
|
indent_str = indent_str .. ","
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
indent_str = indent_str .. "}\n"
|
|
|
|
|
return indent_str
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.Initialize()
|
|
|
|
|
--加载相关模块
|
|
|
|
|
local files = ReloadFile("Modules/Battle/Config/LuaFileConfig")
|
|
|
|
|
LoadLuaFiles(files)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取技能数据(战斗用)
|
|
|
|
|
function this.GetSkillData(skillId, pos)
|
|
|
|
|
pos = pos or 0
|
|
|
|
|
if not skillId or not SkillLogicConfig[skillId] then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
local skill = {skillId}
|
|
|
|
|
--skill = {skillId, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
|
|
|
|
--效果 = {效果类型id, 效果参数1, 效果参数2, ...}
|
|
|
|
|
|
|
|
|
|
local target = SkillLogicConfig[skillId].Target
|
|
|
|
|
local effectList = SkillLogicConfig[skillId].Effect
|
|
|
|
|
local effectArgsList = SkillLogicConfig[skillId].EffectValue
|
|
|
|
|
local EffectCombat = CombatControl[SkillLogicConfig[skillId].SkillDisplay]
|
|
|
|
|
local index = 1
|
|
|
|
|
|
|
|
|
|
for i = 1, #effectList do
|
|
|
|
|
local effectGroup = { target[i][1] } -- 效果目标
|
|
|
|
|
effectGroup[2] = EffectCombat.KeyFrame/1000 -- 效果时间(ms -> s)
|
|
|
|
|
for j = 1, #effectList[i] do
|
|
|
|
|
local effect = { effectList[i][j] } -- 效果Id
|
|
|
|
|
for k = 1, #effectArgsList[index] do
|
|
|
|
|
effect[k + 1] = effectArgsList[index][k] -- 效果参数
|
|
|
|
|
end
|
|
|
|
|
effectGroup[j + 2] = effect
|
|
|
|
|
index = index + 1
|
|
|
|
|
end
|
|
|
|
|
skill[i + 1] = effectGroup
|
|
|
|
|
end
|
|
|
|
|
return skill
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.GetPassivityData(passivityList)
|
|
|
|
|
local pList = {}
|
|
|
|
|
if not passivityList then
|
|
|
|
|
return pList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 遍历被动,检查是否有要覆盖的被动技能
|
|
|
|
|
local orderList = {}
|
|
|
|
|
local coverList = {}
|
|
|
|
|
for i = 1, #passivityList do
|
|
|
|
|
local passiveId = tonumber(passivityList[i])
|
|
|
|
|
local cfg = PassiveSkillLogicConfig[passiveId]
|
|
|
|
|
-- 判断技能是否在战斗中生效
|
|
|
|
|
if cfg and cfg.EffectiveRange == 1 then
|
|
|
|
|
-- 判断是否有需要覆盖的被动技能
|
|
|
|
|
local coverId = cfg.CoverID
|
|
|
|
|
if coverId and coverId ~= 0 then
|
|
|
|
|
if orderList[coverId] then
|
|
|
|
|
orderList[coverId] = nil
|
|
|
|
|
end
|
|
|
|
|
coverList[coverId] = 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 判断该被动技能是否已经被覆盖
|
|
|
|
|
if not coverList[passiveId] then
|
|
|
|
|
-- 没有被覆盖,数据加入
|
|
|
|
|
local pass = {}
|
|
|
|
|
if cfg and cfg.Type ~= 0 then
|
|
|
|
|
pass[1] = cfg.Type
|
|
|
|
|
for j = 1, #cfg.Value do
|
|
|
|
|
pass[j + 1] = cfg.Value[j]
|
|
|
|
|
end
|
|
|
|
|
orderList[passiveId] = pass
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 构建数据
|
|
|
|
|
for _, passive in pairs(orderList) do
|
|
|
|
|
table.insert(pList, passive)
|
|
|
|
|
end
|
|
|
|
|
return pList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取怪物数据(战斗用)
|
|
|
|
|
function this.GetMonsterData(monsterId)
|
|
|
|
|
local monsterConfig = MonsterConfig[monsterId]
|
|
|
|
|
return {
|
|
|
|
|
roleId = monsterConfig.MonsterId,
|
|
|
|
|
monsterId = monsterId, --非战斗数据,仅用于显示怪物名称
|
|
|
|
|
professionId = monsterConfig.Profession,
|
|
|
|
|
camp = 1,
|
|
|
|
|
type = 1,
|
|
|
|
|
quality = 0,
|
|
|
|
|
skill = this.GetSkillData(monsterConfig.SkillList[1]),
|
|
|
|
|
superSkill = this.GetSkillData(monsterConfig.SkillList[2]),
|
|
|
|
|
element = monsterConfig.PropertyName,
|
|
|
|
|
passivity = this.GetPassivityData(monsterConfig.PassiveSkillList),
|
|
|
|
|
property = {
|
|
|
|
|
monsterConfig.Level,
|
|
|
|
|
monsterConfig.Hp,
|
|
|
|
|
monsterConfig.Hp,
|
|
|
|
|
monsterConfig.Attack,
|
|
|
|
|
monsterConfig.PhysicalDefence,
|
|
|
|
|
monsterConfig.MagicDefence,
|
|
|
|
|
monsterConfig.Speed,
|
|
|
|
|
monsterConfig.DamageBocusFactor,
|
|
|
|
|
monsterConfig.DamageReduceFactor,
|
|
|
|
|
monsterConfig.Hit,
|
|
|
|
|
monsterConfig.Dodge,
|
|
|
|
|
monsterConfig.CritFactor,
|
|
|
|
|
monsterConfig.CritDamageFactor,
|
|
|
|
|
monsterConfig.AntiCritDamageFactor,
|
|
|
|
|
monsterConfig.TreatFacter,
|
|
|
|
|
monsterConfig.CureFacter,
|
|
|
|
|
monsterConfig.DifferDemonsBocusFactor,
|
|
|
|
|
monsterConfig.DifferDemonsReduceFactor,
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[1],
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[2],
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[3],
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[4],
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[5],
|
|
|
|
|
monsterConfig.ElementDamageReduceFactor[6],
|
|
|
|
|
monsterConfig.ElementDamageBonusFactor,
|
|
|
|
|
},
|
|
|
|
|
ai = monsterConfig.MonsterAi,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-03 19:09:01 +08:00
|
|
|
|
---获取服务端传过来的战斗数据和随机数种子
|
|
|
|
|
---参数2 isFightPlayer 0和怪物对战 1和玩家对战
|
|
|
|
|
function this.GetBattleServerData(msg, isFightPlayer)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local fightData = {
|
|
|
|
|
playerData = { teamSkill = {}, teamPassive = {} },
|
|
|
|
|
enemyData = {},
|
|
|
|
|
}
|
2020-06-03 19:09:01 +08:00
|
|
|
|
isFightPlayer = isFightPlayer == 1
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local data = msg.fightData.heroFightInfos
|
|
|
|
|
for i = 1, #data.fightUnitList do
|
|
|
|
|
local rid = tonumber(data.fightUnitList[i].unitId)
|
|
|
|
|
local position = tonumber(data.fightUnitList[i].position)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local star = tonumber(data.fightUnitList[i].star)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local skills = string.split(data.fightUnitList[i].unitSkillIds, "#")
|
|
|
|
|
local propertys = string.split(data.fightUnitList[i].property, "#")
|
|
|
|
|
local role = {
|
|
|
|
|
roleId = rid,
|
|
|
|
|
position = position,
|
2020-06-03 19:09:01 +08:00
|
|
|
|
star = star,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
camp = 0,
|
|
|
|
|
type = 1,
|
|
|
|
|
quality = 0,
|
|
|
|
|
element = HeroConfig[rid].PropertyName,
|
|
|
|
|
professionId = HeroConfig[rid].Profession,
|
|
|
|
|
passivity = { },
|
|
|
|
|
property = { },
|
|
|
|
|
}
|
|
|
|
|
if skills[1] then
|
|
|
|
|
role.skill = this.GetSkillData(tonumber(skills[1]))
|
|
|
|
|
end
|
|
|
|
|
if skills[2] and skills[2] ~= "0" then
|
|
|
|
|
role.superSkill = this.GetSkillData(tonumber(skills[2]))
|
|
|
|
|
end
|
|
|
|
|
if #skills > 2 then
|
|
|
|
|
local passivityList = {}
|
|
|
|
|
for j = 3, #skills do
|
|
|
|
|
table.insert(passivityList, tonumber(skills[j]))
|
|
|
|
|
end
|
|
|
|
|
role.passivity = this.GetPassivityData(passivityList)
|
|
|
|
|
end
|
|
|
|
|
for j = 1, #propertys do
|
|
|
|
|
role.property[j] = tonumber(propertys[j])
|
|
|
|
|
end
|
|
|
|
|
fightData.playerData[i] = role
|
|
|
|
|
end
|
|
|
|
|
--Log("teamSkills:"..data.teamSkillList)
|
|
|
|
|
local teamSkills = string.split(data.teamSkillList, "|") --异妖位置1#技能id1|异妖位置2#技能id2|..
|
|
|
|
|
for i = 1, #teamSkills do
|
|
|
|
|
local s = string.split(teamSkills[i], "#")
|
|
|
|
|
fightData.playerData.teamSkill[i] = this.GetSkillData(tonumber(s[2]), tonumber(s[1]))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--Log("data.teamPassiveList:"..data.teamPassiveList)
|
|
|
|
|
local teamPassives = string.split(data.teamPassiveList, "|")
|
|
|
|
|
for i = 1, #teamPassives do
|
|
|
|
|
local s = string.split(teamPassives[i], "#")
|
|
|
|
|
local teamPassiveList = {}
|
|
|
|
|
for j = 1, #s do
|
|
|
|
|
teamPassiveList[j] = tonumber(s[j])
|
|
|
|
|
end
|
|
|
|
|
fightData.playerData.teamPassive[i] = this.GetPassivityData(teamPassiveList)
|
|
|
|
|
end
|
|
|
|
|
|
2020-05-25 19:16:23 +08:00
|
|
|
|
-- 一些战斗外数据
|
|
|
|
|
fightData.playerData.outData = data.specialPassive
|
2020-06-23 18:36:24 +08:00
|
|
|
|
LogRed(Language[10221]..data.specialPassive)
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
2020-05-09 13:31:21 +08:00
|
|
|
|
for i = 1, #msg.fightData.monsterList do
|
|
|
|
|
local data2 = msg.fightData.monsterList[i]
|
|
|
|
|
fightData.enemyData[i] = { teamSkill = {}, teamPassive = {} }
|
|
|
|
|
|
|
|
|
|
for j = 1, #data2.fightUnitList do
|
|
|
|
|
local skills, propertys, role
|
2020-06-03 19:09:01 +08:00
|
|
|
|
if not isFightPlayer then
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local monsterConfig = ConfigManager.GetConfigData(ConfigName.MonsterConfig, tonumber(data2.fightUnitList[j].unitId))
|
|
|
|
|
local position = tonumber(data2.fightUnitList[j].position)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local star = tonumber(data2.fightUnitList[j].star)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
skills = string.split(data2.fightUnitList[j].unitSkillIds, "#")
|
|
|
|
|
propertys = string.split(data2.fightUnitList[j].property, "#")
|
|
|
|
|
role = {
|
|
|
|
|
roleId = monsterConfig.MonsterId,
|
|
|
|
|
monsterId = tonumber(data2.fightUnitList[j].unitId), --非战斗数据,仅用于显示怪物名称
|
|
|
|
|
position = position,
|
2020-06-03 19:09:01 +08:00
|
|
|
|
star = star,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
camp = 1,
|
|
|
|
|
type = monsterConfig.Type,
|
|
|
|
|
quality = monsterConfig.Quality,
|
|
|
|
|
element = monsterConfig.PropertyName,
|
|
|
|
|
ai = monsterConfig.MonsterAi,
|
|
|
|
|
professionId = monsterConfig.Profession,
|
|
|
|
|
passivity = { },
|
|
|
|
|
property = { },
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
local rid = tonumber(data2.fightUnitList[j].unitId)
|
|
|
|
|
local position = tonumber(data2.fightUnitList[j].position)
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local star = tonumber(data2.fightUnitList[j].star)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
skills = string.split(data2.fightUnitList[j].unitSkillIds, "#")
|
|
|
|
|
propertys = string.split(data2.fightUnitList[j].property, "#")
|
|
|
|
|
role = {
|
|
|
|
|
roleId = rid,
|
|
|
|
|
position = position,
|
2020-06-03 19:09:01 +08:00
|
|
|
|
star = star,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
camp = 1,
|
|
|
|
|
type = 1,
|
|
|
|
|
quality = 0,
|
|
|
|
|
element = HeroConfig[rid].PropertyName,
|
|
|
|
|
professionId = HeroConfig[rid].Profession,
|
|
|
|
|
passivity = { },
|
|
|
|
|
property = { },
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if skills[1] then
|
|
|
|
|
role.skill = this.GetSkillData(tonumber(skills[1]))
|
|
|
|
|
end
|
|
|
|
|
if skills[2] and skills[2] ~= "0" then
|
|
|
|
|
role.superSkill = this.GetSkillData(tonumber(skills[2]))
|
|
|
|
|
end
|
|
|
|
|
if #skills > 2 then
|
|
|
|
|
local passivityList = {}
|
|
|
|
|
for k = 3, #skills do
|
|
|
|
|
table.insert(passivityList, tonumber(skills[k]))
|
|
|
|
|
end
|
|
|
|
|
role.passivity = this.GetPassivityData(passivityList)
|
|
|
|
|
end
|
|
|
|
|
for k = 1, #propertys do
|
|
|
|
|
role.property[k] = tonumber(propertys[k])
|
|
|
|
|
end
|
|
|
|
|
fightData.enemyData[i][j] = role
|
|
|
|
|
end
|
|
|
|
|
--Log("teamSkills2:"..data2.teamSkillList)
|
|
|
|
|
local teamSkills2 = string.split(data2.teamSkillList, "|") --异妖位置1#技能id1|异妖位置2#技能id2|..
|
|
|
|
|
for j = 1, #teamSkills2 do
|
|
|
|
|
local s = string.split(teamSkills2[j], "#")
|
|
|
|
|
fightData.enemyData[i].teamSkill[j] = this.GetSkillData(tonumber(s[2]), tonumber(s[1]))
|
|
|
|
|
end
|
2020-05-25 19:16:23 +08:00
|
|
|
|
|
|
|
|
|
-- 一些战斗外数据
|
|
|
|
|
fightData.enemyData[i].outData = data2.specialPassive
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
2020-06-03 19:09:01 +08:00
|
|
|
|
local data = {
|
|
|
|
|
fightData = fightData,
|
|
|
|
|
fightSeed = msg.fightData.fightSeed,
|
|
|
|
|
fightType = msg.fightData.fightType,
|
|
|
|
|
maxRound = msg.fightData.fightMaxTime,
|
|
|
|
|
}
|
|
|
|
|
return data
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取战斗数据(战斗用)
|
|
|
|
|
function this.GetBattleData(formationId, monsterGroupId)
|
|
|
|
|
local fightData = {
|
|
|
|
|
playerData = { teamSkill = {}, teamPassive = {} },
|
|
|
|
|
enemyData = {},
|
|
|
|
|
}
|
|
|
|
|
local pokemonInfos = FormationManager.formationList[formationId].teamPokemonInfos
|
|
|
|
|
local teamHeroInfos = FormationManager.formationList[formationId].teamHeroInfos
|
|
|
|
|
for i = 1, #pokemonInfos do
|
|
|
|
|
Log(DiffMonsterManager.GetSinglePokemonSkillIdData(pokemonInfos[i].pokemonId))
|
|
|
|
|
fightData.playerData.teamSkill[i] = this.GetSkillData(DiffMonsterManager.GetSinglePokemonSkillIdData(pokemonInfos[i].pokemonId), pokemonInfos[i].position)
|
|
|
|
|
fightData.playerData.teamPassive[i] = this.GetPassivityData(DiffMonsterManager.GetSinglePokemonPassiveSkillIdData(pokemonInfos[i].pokemonId))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i = 1, #teamHeroInfos do
|
|
|
|
|
local heroData = HeroManager.GetSingleHeroData(teamHeroInfos[i].heroId)
|
|
|
|
|
if heroData then
|
|
|
|
|
local role = {
|
|
|
|
|
roleId = heroData.id,
|
|
|
|
|
camp = 0,
|
|
|
|
|
type = 1,
|
|
|
|
|
quality = 0,
|
|
|
|
|
element = HeroConfig[heroData.id].PropertyName,
|
|
|
|
|
professionId = heroData.profession,
|
|
|
|
|
--skill = this.GetSkillData(1000112),
|
|
|
|
|
--superSkill = nil,
|
|
|
|
|
passivity = this.GetPassivityData(this.GetTalismanSkillData(heroData.dynamicId)),
|
|
|
|
|
}
|
|
|
|
|
if heroData.skillIdList[1] then
|
|
|
|
|
Log("skillId1:" .. heroData.skillIdList[1].skillId)
|
|
|
|
|
role.skill = this.GetSkillData(heroData.skillIdList[1].skillId)
|
|
|
|
|
end
|
|
|
|
|
if heroData.skillIdList[2] then
|
|
|
|
|
Log("skillId2:" .. heroData.skillIdList[2].skillId)
|
|
|
|
|
role.superSkill = this.GetSkillData(heroData.skillIdList[2].skillId)
|
|
|
|
|
end
|
|
|
|
|
local allPassiveSkillIds = HeroManager.GetHeroAllPassiveSkillIds(heroData)
|
|
|
|
|
if allPassiveSkillIds then
|
|
|
|
|
role.passivity = this.GetPassivityData(allPassiveSkillIds)
|
|
|
|
|
end
|
|
|
|
|
-- if heroData.passiveSkillList[2] then
|
|
|
|
|
-- Log("skillIdPassive2:" .. heroData.passiveSkillList[2].skillId)
|
|
|
|
|
-- local skillPL = this.GetPassivityData({heroData.passiveSkillList[2].skillId})
|
|
|
|
|
-- for i=1, #skillPL do
|
|
|
|
|
-- table.insert(role.passivity, skillPL[i])
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
role.property = HeroManager.CalculateWarAllProVal(heroData.dynamicId)
|
|
|
|
|
fightData.playerData[i] = role
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local Contents = MonsterGroup[monsterGroupId].Contents
|
|
|
|
|
for i = 1, #Contents do
|
|
|
|
|
local enemyList = { teamSkill = {}, teamPassive = {} }
|
|
|
|
|
for j = 1, #Contents[i] do
|
|
|
|
|
enemyList[j] = this.GetMonsterData(Contents[i][j])
|
|
|
|
|
end
|
|
|
|
|
fightData.enemyData[i] = enemyList
|
|
|
|
|
end
|
|
|
|
|
return fightData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 获取我数据
|
|
|
|
|
function this.GetBattlePlayerData(fId)
|
|
|
|
|
fId = fId or 1 -- 默认主线编队
|
|
|
|
|
local playerData = { teamSkill = {}, teamPassive = {} }
|
|
|
|
|
|
|
|
|
|
-- local pokemonInfos = FormationManager.formationList[formationId].teamPokemonInfos
|
|
|
|
|
-- for i = 1, #pokemonInfos do
|
|
|
|
|
-- Log(DiffMonsterManager.GetSinglePokemonSkillIdData(pokemonInfos[i].pokemonId))
|
|
|
|
|
-- fightData.playerData.teamSkill[i] = this.GetSkillData(DiffMonsterManager.GetSinglePokemonSkillIdData(pokemonInfos[i].pokemonId), pokemonInfos[i].position)
|
|
|
|
|
-- fightData.playerData.teamPassive[i] = this.GetPassivityData(DiffMonsterManager.GetSinglePokemonPassiveSkillIdData(pokemonInfos[i].pokemonId))
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
local teamHeroInfos = FormationManager.formationList[fId].teamHeroInfos
|
|
|
|
|
for i = 1, #teamHeroInfos do
|
|
|
|
|
local teamData = teamHeroInfos[i]
|
|
|
|
|
local heroData = HeroManager.GetSingleHeroData(teamData.heroId)
|
|
|
|
|
if heroData then
|
|
|
|
|
local role = {
|
|
|
|
|
roleId = heroData.id,
|
|
|
|
|
position = teamData.position,
|
2020-06-03 19:09:01 +08:00
|
|
|
|
star = heroData.star,
|
2020-05-09 13:31:21 +08:00
|
|
|
|
camp = 0,
|
|
|
|
|
type = 1,
|
|
|
|
|
quality = 0,
|
|
|
|
|
element = HeroConfig[heroData.id].PropertyName,
|
|
|
|
|
professionId = heroData.profession,
|
|
|
|
|
}
|
|
|
|
|
if heroData.skillIdList[1] then
|
|
|
|
|
role.skill = this.GetSkillData(heroData.skillIdList[1].skillId)
|
|
|
|
|
end
|
|
|
|
|
if heroData.skillIdList[2] then
|
|
|
|
|
role.superSkill = this.GetSkillData(heroData.skillIdList[2].skillId)
|
|
|
|
|
end
|
|
|
|
|
local allPassiveSkillIds = HeroManager.GetHeroAllPassiveSkillIds(heroData)
|
|
|
|
|
if allPassiveSkillIds then
|
|
|
|
|
role.passivity = this.GetPassivityData(allPassiveSkillIds)
|
|
|
|
|
end
|
|
|
|
|
role.property = HeroManager.CalculateWarAllProVal(heroData.dynamicId)
|
|
|
|
|
--
|
|
|
|
|
table.insert(playerData, role)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return playerData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 根据怪物组数据
|
|
|
|
|
function this.GetBattleEnemyData(gId)
|
|
|
|
|
-- body
|
|
|
|
|
local enemyData = {}
|
|
|
|
|
local Contents = MonsterGroup[gId].Contents
|
|
|
|
|
for i = 1, #Contents do
|
|
|
|
|
local enemyList = { teamSkill = {}, teamPassive = {} }
|
|
|
|
|
for j = 1, #Contents[i] do
|
|
|
|
|
if Contents[i][j] ~= 0 then
|
|
|
|
|
local data = this.GetMonsterData(Contents[i][j])
|
|
|
|
|
data.position = j
|
|
|
|
|
table.insert(enemyList, data)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
enemyData[i] = enemyList
|
|
|
|
|
end
|
|
|
|
|
return enemyData
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--获取单个英雄装备被动技能list
|
|
|
|
|
--function this.GetSingHeroAllEquipSkillListData(_heroId)
|
|
|
|
|
-- local allEquipSkillList = {}
|
|
|
|
|
-- local curHeroData = HeroManager.GetSingleHeroData(_heroId)
|
|
|
|
|
-- if curHeroData then
|
|
|
|
|
-- for i = 1, #curHeroData.equipIdList do
|
|
|
|
|
-- local curEquip = EquipManager.equipDatas[curHeroData.equipIdList[i]]
|
|
|
|
|
-- if curEquip then
|
|
|
|
|
-- if curEquip.skillId and curEquip.skillId > 0 then
|
|
|
|
|
-- table.insert(allEquipSkillList, curEquip.skillId)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- return allEquipSkillList
|
|
|
|
|
--end
|
|
|
|
|
--获取单个英雄法宝被动技能list
|
|
|
|
|
function this.GetTalismanSkillData(_heroId)
|
|
|
|
|
local allTalismanSkillList = {}
|
|
|
|
|
local curHeroData = HeroManager.GetSingleHeroData(_heroId)
|
|
|
|
|
if curHeroData then
|
|
|
|
|
for i = 1, #curHeroData.talismanList do
|
|
|
|
|
local curTalisman = TalismanManager.GetSingleTalismanData(curHeroData.talismanList[i])
|
|
|
|
|
if curTalisman then
|
|
|
|
|
local talismanConFig = ConfigManager.GetConfigDataByDoubleKey(ConfigName.EquipTalismana, "TalismanaId", curTalisman.backData.equipId,"Level",curTalisman.star)
|
|
|
|
|
if talismanConFig then
|
|
|
|
|
for j = 1, #talismanConFig.OpenSkillRules do
|
|
|
|
|
table.insert(allTalismanSkillList, talismanConFig.OpenSkillRules[j])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return allTalismanSkillList
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取技能表现
|
|
|
|
|
local _CombatList = {}
|
|
|
|
|
function this.GetSkillCombat(id)
|
|
|
|
|
if not _CombatList[id] then
|
|
|
|
|
local combat = CombatControl[id]
|
|
|
|
|
if not combat then return end
|
|
|
|
|
_CombatList[id] = {
|
|
|
|
|
Id = combat.Id,
|
|
|
|
|
SkillType = combat.SkillType,
|
|
|
|
|
VerticalDrawing = combat.VerticalDrawing,
|
|
|
|
|
KeyFrame = combat.KeyFrame,
|
|
|
|
|
Eterm = combat.Eterm,
|
|
|
|
|
ShockScreen = combat.ShockScreen,
|
|
|
|
|
Bullet = combat.Bullet,
|
|
|
|
|
BulletTime = combat.BulletTime,
|
|
|
|
|
Hit = combat.Hit,
|
|
|
|
|
Offset = combat.Offset,
|
|
|
|
|
skillname = combat.skillname,
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
return _CombatList[id]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.SetSkillCombat(id, combat)
|
|
|
|
|
_CombatList[id] = combat
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
----- 战斗控制相关 ------------------
|
|
|
|
|
-- 是否解锁二倍速
|
|
|
|
|
function this.IsUnlockBattleSpeed()
|
|
|
|
|
return PrivilegeManager.GetPrivilegeOpenStatus(PRIVILEGE_TYPE.DoubleTimesFight)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 是否解锁跳过功能
|
|
|
|
|
function this.IsUnlockBattlePass()
|
2020-06-03 19:09:01 +08:00
|
|
|
|
return false
|
|
|
|
|
-- return PrivilegeManager.GetPrivilegeOpenStatus(PRIVILEGE_TYPE.SkipFight or PRIVILEGE_TYPE.ExitFight)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- 战斗暂停控制
|
|
|
|
|
this.IsPlay = 0
|
|
|
|
|
function this.StartBattle()
|
|
|
|
|
if this.IsPlay == 0 then
|
|
|
|
|
this.IsPlay = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function this.IsBattlePlaying()
|
|
|
|
|
return this.IsPlay == 1
|
|
|
|
|
end
|
|
|
|
|
function this.PauseBattle()
|
|
|
|
|
if this.IsPlay == 1 then
|
|
|
|
|
this.IsPlay = 2
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function this.ResumeBattle()
|
|
|
|
|
if this.IsPlay == 2 then
|
|
|
|
|
this.IsPlay = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
function this.StopBattle()
|
|
|
|
|
this.IsPlay = 0
|
|
|
|
|
end
|
2020-05-15 16:52:35 +08:00
|
|
|
|
function this.IsCanOperate()
|
|
|
|
|
return this.IsPlay ~= 0
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
|
|
|
|
-- 战斗加速控制
|
|
|
|
|
BATTLE_TIME_SCALE_ZERO = 0
|
|
|
|
|
BATTLE_TIME_SCALE_ONE= 1.1
|
|
|
|
|
BATTLE_TIME_SCALE_TWO = 2
|
|
|
|
|
this.TimeScale = 0
|
|
|
|
|
function this.InitTimeScale()
|
2020-05-25 19:16:23 +08:00
|
|
|
|
this.TimeScale = 0
|
2020-05-09 13:31:21 +08:00
|
|
|
|
local _TimeScale = PlayerPrefs.GetFloat("battleTimeScaleKey", BATTLE_TIME_SCALE_ONE)
|
|
|
|
|
this.SetTimeScale(_TimeScale)
|
|
|
|
|
end
|
|
|
|
|
function this.GetTimeScale()
|
|
|
|
|
return this.TimeScale
|
|
|
|
|
end
|
|
|
|
|
function this.SetTimeScale(TimeScale)
|
|
|
|
|
--
|
|
|
|
|
if TimeScale < 0 or not this.IsUnlockBattleSpeed() then--or this.IsFirstBattle()then
|
|
|
|
|
TimeScale = BATTLE_TIME_SCALE_ONE
|
|
|
|
|
end
|
|
|
|
|
--
|
|
|
|
|
if TimeScale > BATTLE_TIME_SCALE_TWO then
|
|
|
|
|
TimeScale = BATTLE_TIME_SCALE_TWO
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if this.TimeScale ~= TimeScale then
|
|
|
|
|
this.TimeScale = TimeScale
|
2020-05-25 19:16:23 +08:00
|
|
|
|
PlayerPrefs.SetFloat("battleTimeScaleKey", this.TimeScale)
|
2020-05-09 13:31:21 +08:00
|
|
|
|
-- 刷新前端显示
|
|
|
|
|
Game.GlobalEvent:DispatchEvent(GameEvent.Battle.OnTimeScaleChanged)
|
|
|
|
|
-- 真正生效的敌方
|
|
|
|
|
Time.timeScale = TimeScale
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- 获取战斗界面层级
|
|
|
|
|
function this.GetBattleSorting()
|
|
|
|
|
if UIManager.IsOpen(UIName.BattlePanel) then
|
|
|
|
|
return BattlePanel.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if UIManager.IsOpen(UIName.BattleTestPanel) then
|
|
|
|
|
return BattleTestPanel.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2020-06-18 20:39:29 +08:00
|
|
|
|
-- 获取战斗背景
|
|
|
|
|
local bgConfig = {
|
|
|
|
|
[1] = "r_zhandou_changjing017",
|
|
|
|
|
[2] = "r_zhandou_changjing016",
|
2020-06-19 21:44:27 +08:00
|
|
|
|
[3] = "r_zhandou_changjing017",
|
|
|
|
|
[1001] = "r_zhandou_changjing018",
|
|
|
|
|
[1002] = "r_zhandou_changjing019",
|
2020-06-18 20:39:29 +08:00
|
|
|
|
}
|
|
|
|
|
function this.GetBattleBg(fightType)
|
|
|
|
|
if fightType == BATTLE_TYPE.STORY_FIGHT then
|
|
|
|
|
local curChapter = FightPointPassManager.GetCurChapterIndex()
|
2020-06-19 21:44:27 +08:00
|
|
|
|
local index = math.floor((curChapter + 1) % 3 + 1)
|
2020-06-18 20:39:29 +08:00
|
|
|
|
return bgConfig[index]
|
2020-06-19 20:19:35 +08:00
|
|
|
|
elseif fightType == BATTLE_TYPE.BACK then
|
2020-06-19 21:44:27 +08:00
|
|
|
|
return bgConfig[1001]
|
|
|
|
|
elseif fightType == BATTLE_TYPE.EXECUTE_FIGHT then
|
|
|
|
|
return bgConfig[1002]
|
2020-06-18 20:39:29 +08:00
|
|
|
|
else
|
|
|
|
|
return bgConfig[1]
|
|
|
|
|
end
|
|
|
|
|
end
|
2020-05-09 13:31:21 +08:00
|
|
|
|
|
2020-06-23 18:36:24 +08:00
|
|
|
|
return this
|