添加容错

This commit is contained in:
xiekaidong 2023-06-25 10:30:21 +08:00
parent 54242318ed
commit 16c0fe7182
2 changed files with 18 additions and 5 deletions

View File

@ -166,6 +166,9 @@ end
function CharacterSpineObject:playAnimation(animName, loop, forceRefresh)
if self.characterSpineHelper then
if not self:getAnimationExist(animName) then
return
end
self.characterSpineHelper:PlayAnimation(animName, loop, forceRefresh)
end
end
@ -209,14 +212,21 @@ function CharacterSpineObject:getAnimationDuration(animationName)
return 0
end
function CharacterSpineObject:getAnimationExist(animationName)
local animation = self:getSkeletonGraphic().skeletonDataAsset:GetAnimationStateData().SkeletonData:FindAnimation(animationName)
return animation ~= nil
end
function CharacterSpineObject:getAnimationKeyFrameTimes(animationName)
local times = {}
if self.characterSpineHelper then
local timeList = self.characterSpineHelper:GetAnimationKeyFrameTime(animationName)
local count = timeList.Count
if count > 0 then
for i = 1, count do
table.insert(times, timeList[i - 1])
if self:getAnimationExist(animationName) then
local timeList = self.characterSpineHelper:GetAnimationKeyFrameTime(animationName)
local count = timeList.Count
if count > 0 then
for i = 1, count do
table.insert(times, timeList[i - 1])
end
end
end
end

View File

@ -996,6 +996,9 @@ function BattleUnitComp:updateSkillAttack(dt)
self:doNextNormalAttack()
end
else
if self.currAttackDuration <= 0 and self.currActiveSkill then -- 当前动画异常 没有进入onSkillTakeEffect不会攻击次数减一所以手动调用一次
self.currActiveSkill:endUse()
end
local currActiveSkill = nil
local skillCanUseTimes = self.currActiveSkill:getSkillCanUseTimes()
if skillCanUseTimes and skillCanUseTimes > 0 then -- 当前技能可以多次使用