[战斗]========battleutil 添加判断数组长度方法

dev_chengFeng
wangzhenxing 2021-04-07 20:14:43 +08:00
parent 894a8bcfd4
commit dada859ec6
5 changed files with 11 additions and 7 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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]

View File

@ -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()