From dada859ec6dd0bc99de0f644462bac086152b232 Mon Sep 17 00:00:00 2001 From: wangzhenxing Date: Wed, 7 Apr 2021 20:14:43 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=88=98=E6=96=97]=3D=3D=3D=3D=3D=3D=3D=3Dbat?= =?UTF-8?q?tleutil=20=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E9=95=BF=E5=BA=A6=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../~Lua/Modules/Battle/Logic/BattleLogic.lua | 3 --- .../~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua | 9 ++++++++- .../Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua | 2 +- .../~Lua/Modules/Battle/Logic/Role/RoleLogic.lua | 2 +- .../~Lua/Modules/Battle/Logic/Role/Skill.lua | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/BattleLogic.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/BattleLogic.lua index 2ad8cbe21c..ef2e1f797c 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/BattleLogic.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/BattleLogic.lua @@ -104,7 +104,6 @@ end -- 检测先手阵营 function BattleLogic.CheckFirstCamp() - Log("检测先后手") -- 默认我方先手 BattleLogic.FirstCamp = 0 -- 数据不存在时,兼容老战斗数据 @@ -227,7 +226,6 @@ function BattleLogic.TurnRound(debugTurn) SkillManager.CheckMonsterSkill(function() CurRound = CurRound + 1 CurCamp = BattleLogic.FirstCamp -- 判断先手阵营 - Log("BattleLogic.230:"..tostring(CurCamp)) CurSkillPos[0] = 0 CurSkillPos[1] = 0 -- @@ -259,7 +257,6 @@ function BattleLogic.TurnRound(debugTurn) BattleLogic.WaitForTrigger(0.2,function() -- 切换阵营 CurCamp = (CurCamp + 1) % 2 - Log("BattleLogic.260:"..tostring(CurCamp)) BattleLogic.CheckBattleLogic() end) end) diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua index e4db578d20..8d1dd35252 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Misc/BattleUtil.lua @@ -931,7 +931,14 @@ function BattleUtil.CheckIsHit(atkRole, defRole,skill) end - +--获取table的长度 +function BattleUtil.LengthOfTable(table) + local length = 0 + for i, v in pairs(table) do + length = length + 1 + end + return length +end function BattleUtil.RandomAction(rand, action) if Random.Range01() <= rand and action then diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua index 7a3d1d1a00..f09ad9c3ec 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Monster/MonsterSkill/MSkill.lua @@ -66,7 +66,7 @@ function MSkill:Cast(func) --放技能前判断是否有目标,没有就不会放技能,直接执行技能回调 by 王振兴 2021/03/26 --为解决攻击目标只剩被放逐的单位导致技能播放异常 self.effectCaster:ChooseTarget() - local targets=LengthOfTable(self:GetDirectTargetsNoExile()) + local targets=BattleUtil.LengthOfTable(self:GetDirectTargetsNoExile()) if targets==0 and self.castDoneFunc then self.castDoneFunc() return diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/RoleLogic.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/RoleLogic.lua index 9d4d0979c6..da8947ebdc 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/RoleLogic.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/RoleLogic.lua @@ -84,7 +84,7 @@ function RoleLogic:Init(uid, data, position) self.type = BattleUnitType.Role self.passiveList = {} if data.passivity and #data.passivity > 0 then - table.sort(data.passivity,function(a,b)return a[1] < b[1] end) + table.sort(data.passivity,function(a,b)return a[1] < b[1] end) for i = 1, #data.passivity do local v = data.passivity[i] local passivityId=v[1] diff --git a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/Skill.lua b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/Skill.lua index 92533efb58..b8a4efca4f 100644 --- a/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/Skill.lua +++ b/Assets/ManagedResources/~Lua/Modules/Battle/Logic/Role/Skill.lua @@ -67,7 +67,7 @@ function Skill:Cast(func) --放技能前判断是否有目标,没有就不会放技能,直接执行技能回调 by 王振兴 2021/03/26 --为解决攻击目标只剩被放逐的单位导致技能播放异常 self.effectCaster:ChooseTarget() - local targets=LengthOfTable(self:GetDirectTargetsNoExile()) + local targets=BattleUtil.LengthOfTable(self:GetDirectTargetsNoExile()) if targets==0 and self.castDoneFunc then self.isRage=false self.castDoneFunc()