From bd54aea85ef7a1c364e4cef11183ea0eb54462f8 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Thu, 20 Feb 2020 16:06:48 +0800 Subject: [PATCH] fight --- luafight/Modules/Battle/Logic/BattleLogic.lua | 49 +++++++++++++------ .../Battle/Logic/Misc/BattleDefine.lua | 1 + 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/luafight/Modules/Battle/Logic/BattleLogic.lua b/luafight/Modules/Battle/Logic/BattleLogic.lua index 386637941..ddd6f670c 100644 --- a/luafight/Modules/Battle/Logic/BattleLogic.lua +++ b/luafight/Modules/Battle/Logic/BattleLogic.lua @@ -12,6 +12,9 @@ local curFrame local playerSkillUsable local enemySkillUsable +local bMyAllDead +local bEnemyAllDead + BattleLogic.Type = 0 --1 故事副本 2 地图探索 3 竞技场 4 秘境boss 5 解锁秘境 6 公会战 7 血战 8 兽潮 9巅峰战 BattleLogic.IsEnd = false BattleLogic.Result = -1 @@ -93,6 +96,9 @@ function BattleLogic.Init(maxTime, data, optionData) playerSkillUsable = true enemySkillUsable = true + bMyAllDead = false + bEnemyAllDead = false + BattleLogic.Event:ClearEvent() BattleLogic.BuffMgr:Init() BattleLogic.IsEnd = false @@ -132,7 +138,7 @@ function BattleLogic.StartOrder() for k = 2, #v do args[k-1] = v[k] end - BattleUtil.Passivity[id](playerTeamDummyRole, args) + BattleLogic.TakeTeamPassivity(playerTeamDummyRole, id, args) end end @@ -155,7 +161,7 @@ function BattleLogic.StartOrder() for k = 2, #v do args[k-1] = v[k] end - BattleUtil.Passivity[id](enemyTeamDummyRole, args) + BattleLogic.TakeTeamPassivity(enemyTeamDummyRole, id, args) end end else @@ -181,12 +187,20 @@ function BattleLogic.StartOrder() for k = 2, #v do args[k-1] = v[k] end - BattleUtil.Passivity[id](enemyTeamDummyRole, args) + BattleLogic.TakeTeamPassivity(enemyTeamDummyRole, id, args) end end end end +function BattleLogic.TakeTeamPassivity(teamCaster, id, args) + for i=1, objList.size do + if objList.vList[i].camp == teamCaster.camp then + BattleUtil.Passivity[id](objList.vList[i], args) + end + end +end + function BattleLogic.GetTeamSkill(camp, pos) if camp == 0 then return playerTeamSkillList[pos] @@ -360,6 +374,18 @@ function BattleLogic.Update() BattleLogic.BattleEnd(0) return end + if bMyAllDead then + BattleLogic.BattleEnd(0) + return + end + if bEnemyAllDead then + if BattleLogic.CurOrder == BattleLogic.TotalOrder then + BattleLogic.BattleEnd(1) + else + BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderChange, BattleLogic.CurOrder + 1) + BattleLogic.StartOrder() + end + end curStageFrame = curStageFrame + 1 @@ -400,8 +426,8 @@ function BattleLogic.Update() BattleLogic.BuffMgr:Update() - local bMyAllDead = true - local bEnemyAllDead = true + bMyAllDead = true + bEnemyAllDead = true for i=1, objList.size do local tmpObj = objList.vList[i] if not tmpObj.isDead then @@ -413,17 +439,8 @@ function BattleLogic.Update() end end end - if bMyAllDead then - BattleLogic.BattleEnd(0) - return - end - if bEnemyAllDead then - if BattleLogic.CurOrder == BattleLogic.TotalOrder then - BattleLogic.BattleEnd(1) - else - BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderChange, BattleLogic.CurOrder + 1) - BattleLogic.StartOrder() - end + if bEnemyAllDead and BattleLogic.CurOrder < BattleLogic.TotalOrder then + BattleLogic.Event:DispatchEvent(BattleEventName.BattleOrderEnd, BattleLogic.CurOrder) end end diff --git a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua index 2bb5e2e7d..9e689b82a 100644 --- a/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua +++ b/luafight/Modules/Battle/Logic/Misc/BattleDefine.lua @@ -6,6 +6,7 @@ end BattleEventName = { BattleOrderChange = indexAdd(), + BattleOrderEnd = indexAdd(), BattleStageChange = indexAdd(), BattleEnd = indexAdd(), AddRole = indexAdd(),