Merge branch 'china/dev' of http://60.1.1.230/gaoxin/JL_Client into china/dev

liujiaqi 2021-11-09 23:44:00 +08:00
commit 750761f866
2 changed files with 160 additions and 72 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 313 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -2,92 +2,161 @@ require("Modules.Battle.Logic.Monster.MonsterSkill.MCondition")
MTrigger = {} MTrigger = {}
local this = MTrigger local this = MTrigger
-- local _TriggerConfig = {
-- [1] = { --1敌方单位行动前
-- event = BattleEventName.RoleTurnStart,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local role = args[1]
-- return role.camp ~= skill.owner.camp
-- end
-- },
-- [2] = {--2敌方单位行动后
-- event = BattleEventName.RoleTurnEnd,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local role = args[1]
-- return role.camp ~= skill.owner.camp
-- end
-- },
-- [3] = {--3我方单位行动前
-- event = BattleEventName.RoleTurnStart,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local role = args[1]
-- return role.camp == skill.owner.camp
-- end
-- },
-- [4] = {--4我方单位行动后
-- event = BattleEventName.RoleTurnEnd,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local role = args[1]
-- return role.camp == skill.owner.camp
-- end
-- },
-- [5] = {--5战前
-- event = BattleEventName.BattleStart,
-- triggerFunc = function(skill, ...)
-- return true
-- end
-- },
-- [6] = {--6奇数回合开始前
-- event = BattleEventName.BattleRoundStart,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local curRound = args[1]
-- return curRound%2 == 1
-- end
-- },
-- [7] = {--7偶数回合开始前
-- event = BattleEventName.BattleRoundStart,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local curRound = args[1]
-- return curRound%2 == 0
-- end
-- },
-- [8] = {--8奇数回合结束后
-- event = BattleEventName.BattleRoundEnd,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local curRound = args[1]
-- return curRound%2 == 1
-- end
-- },
-- [9] = {--9偶数回合结束后
-- event = BattleEventName.BattleRoundEnd,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local curRound = args[1]
-- return curRound%2 == 0
-- end
-- },
-- [10] = {--10回合开始前
-- event = BattleEventName.BattleRoundStart,
-- triggerFunc = function(skill, ...)
-- return true
-- end
-- },
-- [11] = {--11回合结束后
-- event = BattleEventName.BattleRoundEnd,
-- triggerFunc = function(skill, ...)
-- return true
-- end
-- },
-- [12] = {--12我方单位释放技能后
-- event = BattleEventName.SkillCastEnd,
-- triggerFunc = function(skill, ...)
-- local args = {...}
-- local castSkill = args[1]
-- return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special)
-- end
-- },
-- }
local _TriggerConfig = { local _TriggerConfig = {
[1] = { --1敌方单位行动前 [BattleEventName.RoleTurnStart] = {
event = BattleEventName.RoleTurnStart, [1] = function(skill, ...) --1敌方单位行动前
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local role = args[1] local role = args[1]
return role.camp ~= skill.owner.camp return role.camp ~= skill.owner.camp
end end,
}, [3] = function(skill, ...) --3我方单位行动前
[2] = {--2敌方单位行动后
event = BattleEventName.RoleTurnEnd,
triggerFunc = function(skill, ...)
local args = {...}
local role = args[1]
return role.camp ~= skill.owner.camp
end
},
[3] = {--3我方单位行动前
event = BattleEventName.RoleTurnStart,
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local role = args[1] local role = args[1]
return role.camp == skill.owner.camp return role.camp == skill.owner.camp
end end
}, },
[4] = {--4我方单位行动后 [BattleEventName.RoleTurnEnd] = {
event = BattleEventName.RoleTurnEnd, [2] = function(skill, ...)--2敌方单位行动后
triggerFunc = function(skill, ...) local args = {...}
local role = args[1]
return role.camp ~= skill.owner.camp
end,
[4] = function(skill, ...)--4我方单位行动后
local args = {...} local args = {...}
local role = args[1] local role = args[1]
return role.camp == skill.owner.camp return role.camp == skill.owner.camp
end end
}, },
[5] = {--5战前 [BattleEventName.BattleStart] = {
event = BattleEventName.BattleStart, [5] = function(skill, ...)--5战前
triggerFunc = function(skill, ...)
return true return true
end end
}, },
[6] = {--6奇数回合开始前 [BattleEventName.BattleRoundStart] = {
event = BattleEventName.BattleRoundStart, [6] = function(skill, ...)--6奇数回合开始前
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local curRound = args[1] local curRound = args[1]
return curRound%2 == 1 return curRound%2 == 1
end end,
}, [7] = function(skill, ...)--7偶数回合开始前
[7] = {--7偶数回合开始前
event = BattleEventName.BattleRoundStart,
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local curRound = args[1] local curRound = args[1]
return curRound%2 == 0 return curRound%2 == 0
end,
[10] = function(skill, ...)--10回合开始前
return true
end end
}, },
[8] = {--8奇数回合结束后 [BattleEventName.BattleRoundEnd] = {
event = BattleEventName.BattleRoundEnd, [8] = function(skill, ...)--8奇数回合结束后
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local curRound = args[1] local curRound = args[1]
return curRound%2 == 1 return curRound%2 == 1
end end,
}, [9] = function(skill, ...)--9偶数回合结束后
[9] = {--9偶数回合结束后
event = BattleEventName.BattleRoundEnd,
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local curRound = args[1] local curRound = args[1]
return curRound%2 == 0 return curRound%2 == 0
end end,
}, [11] = function(skill, ...)--11回合结束后
[10] = {--10回合开始前
event = BattleEventName.BattleRoundStart,
triggerFunc = function(skill, ...)
return true return true
end end
}, },
[11] = {--11回合结束后 [BattleEventName.SkillCastEnd] = {
event = BattleEventName.BattleRoundEnd, [12] = function(skill, ...)--12我方单位释放技能后
triggerFunc = function(skill, ...)
return true
end
},
[12] = {--12我方单位释放技能后
event = BattleEventName.SkillCastEnd,
triggerFunc = function(skill, ...)
local args = {...} local args = {...}
local castSkill = args[1] local castSkill = args[1]
return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special) return castSkill.owner.camp == skill.owner.camp and castSkill.owner.job==2 and (castSkill.type==BattleSkillType.DeadSkill or castSkill.type==BattleSkillType.Extra or castSkill.type==BattleSkillType.Special)
@ -104,31 +173,47 @@ end
function this.InitListener() function this.InitListener()
--每次初始化时间监听前 清除下缓存数据 --每次初始化时间监听前 清除下缓存数据
MCondition.ClearCache() MCondition.ClearCache()
for triggerId, config in pairs(_TriggerConfig) do for event, list in pairs(_TriggerConfig) do
BattleLogic.Event:AddEvent(config.event, function(...) BattleLogic.Event:AddEvent(event, function(...)
-- 用于排序
local firstList = {}
-- 用于排序 -- 用于排序
local sortList = {} local sortList = {}
for triggerId, triggerFunc in pairs(list) do
-- 判断是否有需要触发的技能 -- 判断是否有需要触发的技能
local triggerSkill = this.TriggerList[triggerId] local triggerSkill = this.TriggerList[triggerId]
if not triggerSkill then if triggerSkill then
return
end
for _, trigger in ipairs(triggerSkill) do for _, trigger in ipairs(triggerSkill) do
local skill = trigger.skill local skill = trigger.skill
local condition = trigger.condition local condition = trigger.condition
-- 判断技能是否可以释放 -- 判断技能是否可以释放
if skill:canCastSkill() then if skill:canCastSkill() then
-- 判断是否符合触发类型条件 -- 判断是否符合触发类型条件
if config.triggerFunc(skill, ... ) then if triggerFunc(skill, ... ) then
-- 检测是否符合子条件 -- 检测是否符合子条件
if MCondition.CheckCondition(skill, condition) then if MCondition.CheckCondition(skill, condition) then
-- 加入技能排序对列 -- 加入技能排序对列
if skill.owner.position == 100 then
table.insert(firstList, skill)
else
table.insert(sortList, skill) table.insert(sortList, skill)
end end
end end
end end
end end
end
end
end
-- 对技能进行排序
table.sort(firstList, function(a, b)
-- 同阵营按位置排序
if a.owner.camp == b.owner.camp then
return a.owner.position < b.owner.position
else
-- 不同阵营的根据先手阵营排序
return a.owner.camp == BattleLogic.FirstCamp
end
end)
-- 对技能进行排序 -- 对技能进行排序
table.sort(sortList, function(a, b) table.sort(sortList, function(a, b)
-- 同阵营按位置排序 -- 同阵营按位置排序
@ -140,6 +225,9 @@ function this.InitListener()
end end
end) end)
-- 依次加入技能管理 -- 依次加入技能管理
for _, skill in ipairs(firstList) do
SkillManager.AddMonsterSkill(skill)
end
for _, skill in ipairs(sortList) do for _, skill in ipairs(sortList) do
SkillManager.AddMonsterSkill(skill) SkillManager.AddMonsterSkill(skill)
end end