[战斗]============= 获取数组的长度方法修改

dev_chengFeng
wangzhenxing 2021-03-30 11:08:55 +08:00
parent f81e8ecaab
commit 27e4ab6e1a
3 changed files with 10 additions and 3 deletions

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

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