多段伤害的更改
This commit is contained in:
parent
9c87bbc5d7
commit
77a9039092
@ -202,11 +202,18 @@ function CharacterSpineObject:getAnimationDuration(animationName)
|
||||
return 0
|
||||
end
|
||||
|
||||
function CharacterSpineObject:getAnimationKeyFrameTime(animationName)
|
||||
function CharacterSpineObject:getAnimationKeyFrameTimes(animationName)
|
||||
local times = {}
|
||||
if self.characterSpineHelper then
|
||||
return self.characterSpineHelper:GetAnimationKeyFrameTime(animationName)
|
||||
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
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return times
|
||||
end
|
||||
|
||||
function CharacterSpineObject:addAnimationCompleteCallback(callback)
|
||||
|
||||
@ -258,39 +258,40 @@ function BattleUnitComp:getAnimationDuration(aniName)
|
||||
return duration or 0
|
||||
end
|
||||
|
||||
function BattleUnitComp:getAnimationKeyFrameTime(animationName)
|
||||
local time = self.attackKeyFrameTimeMap[animationName]
|
||||
if time == nil then
|
||||
time = self.baseObject:getAnimationKeyFrameTime(animationName)
|
||||
if time <= 0 then -- 容错处理
|
||||
time = 0.3
|
||||
function BattleUnitComp:getAnimationKeyFrameTime(animationName, index)
|
||||
index = index or 1
|
||||
local timeList = self.attackKeyFrameTimeMap[animationName]
|
||||
if timeList == nil then
|
||||
timeList = self.baseObject:getAnimationKeyFrameTimes(animationName)
|
||||
if not timeList[1] then
|
||||
table.insert(timeList, 0.3)
|
||||
end
|
||||
self.attackKeyFrameTimeMap[animationName] = time
|
||||
self.attackKeyFrameTimeMap[animationName] = timeList
|
||||
end
|
||||
return time
|
||||
return timeList[index] or 0.3
|
||||
end
|
||||
|
||||
function BattleUnitComp:getKeyFrameTime(skill, blockIndex, animationName)
|
||||
self.validEffectIdx[1] = 1
|
||||
self.validEffectIdx[2] = 1
|
||||
if not skill then
|
||||
return 0
|
||||
end
|
||||
|
||||
self.currAttackBlockIndex = blockIndex
|
||||
local time = skill:getEffectBlockTime()[blockIndex]
|
||||
if not time then
|
||||
if blockIndex == 1 then
|
||||
time = self:getAnimationKeyFrameTime(animationName)
|
||||
else
|
||||
time = 0
|
||||
end
|
||||
else
|
||||
local time = 0
|
||||
local blockList = skill:getEffectBlock()
|
||||
if blockList[blockIndex] then
|
||||
local beforeIndex = blockIndex - 1
|
||||
self.validEffectIdx[1] = blockList[beforeIndex] or 1
|
||||
self.validEffectIdx[1] = blockList[beforeIndex] or 0
|
||||
self.validEffectIdx[2] = blockList[blockIndex] or 1
|
||||
time = skill:getEffectBlockTime()[blockIndex]
|
||||
if not time then
|
||||
time = self:getAnimationKeyFrameTime(animationName, blockIndex)
|
||||
end
|
||||
end
|
||||
-- Logger.logHighlight(animationName .. " blockIndex " .. blockIndex)
|
||||
-- Logger.printTable(blockList)
|
||||
|
||||
-- Logger.printTable(self.validEffectIdx)
|
||||
return time
|
||||
end
|
||||
|
||||
@ -298,12 +299,17 @@ function BattleUnitComp:getIsCentralizedAttack()
|
||||
return self.team:getCentralizedAttack()
|
||||
end
|
||||
|
||||
function BattleUnitComp:getIsFinalBlock()
|
||||
return self.team:getIsFinalBlock()
|
||||
end
|
||||
|
||||
function BattleUnitComp:getCurAttackActionState()
|
||||
return self.curAttackActionState
|
||||
end
|
||||
|
||||
function BattleUnitComp:beforeAttack(actionState)
|
||||
self.team:setCentralizedAttack(true)
|
||||
self.team:setIsFinalBlock(false)
|
||||
self.battleController:setIsPauseHpProgress(true)
|
||||
self.curAttackActionState = actionState
|
||||
if actionState == BattleConst.ATTACK_ACTION_STATE.NORMAL then
|
||||
@ -852,13 +858,16 @@ function BattleUnitComp:updateAssistingAttackState(dt)
|
||||
else
|
||||
if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用
|
||||
local skill = self.unitEntity:getAssistingSkill()
|
||||
local isFinalBlock = skill and skill:isFinalBlock(self.currAttackBlockIndex)
|
||||
self:onSkillTakeEffect(skill, isFinalBlock, self.validEffectIdx)
|
||||
|
||||
if skill then
|
||||
local attackName = skill:getSkillAttackName()
|
||||
self.currAttackKeyTime = self:getKeyFrameTime(skill, self.currAttackBlockIndex + 1, attackName)
|
||||
else
|
||||
self.currAttackKeyTime = 0
|
||||
end
|
||||
self:onSkillTakeEffect(skill, self.currAttackKeyTime <= 0, self.validEffectIdx)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -998,34 +1007,37 @@ function BattleUnitComp:updateSkillAttack(dt)
|
||||
if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用
|
||||
if self.normalSkillCount > 0 then
|
||||
local skill = self.unitEntity:getNormalSkill()
|
||||
local isFinalBlock = skill and skill:isFinalBlock(self.currAttackBlockIndex)
|
||||
|
||||
if self.normalSkillCount == 1 and self.currActiveSkill == nil and isFinalBlock then -- 最后一次攻击
|
||||
self.team:setCentralizedAttack(false)
|
||||
end
|
||||
self:onSkillTakeEffect(skill, isFinalBlock, self.validEffectIdx)
|
||||
if self.normalSkillCount == 1 and self.currActiveSkill == nil and isFinalBlock then -- 最后一次攻击
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
|
||||
if skill then
|
||||
local attackName = skill:getSkillAttackName()
|
||||
self.currAttackKeyTime = self:getKeyFrameTime(skill, self.currAttackBlockIndex + 1, attackName)
|
||||
else
|
||||
self.currAttackKeyTime = 0
|
||||
end
|
||||
local isFinalBlock = self.currAttackKeyTime <= 0
|
||||
|
||||
if self.normalSkillCount == 1 and self.currActiveSkill == nil and isFinalBlock then -- 最后一次攻击
|
||||
self.team:setCentralizedAttack(false)
|
||||
end
|
||||
self:onSkillTakeEffect(skill, self.currAttackKeyTime <= 0, self.validEffectIdx)
|
||||
if self.normalSkillCount == 1 and self.currActiveSkill == nil and isFinalBlock then -- 最后一次攻击
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
else
|
||||
local attackName = self.currActiveSkill:getSkillAttackName()
|
||||
self.currAttackKeyTime = self:getKeyFrameTime(self.currActiveSkill, self.currAttackBlockIndex + 1, attackName)
|
||||
local isFinalBlock = self.currAttackKeyTime <= 0
|
||||
local isFinalBlock = self.currActiveSkill:isFinalBlock(self.currAttackBlockIndex)
|
||||
|
||||
local isHaveNextAttack = self:getIsHaveNextAvailableActiveSkill()
|
||||
if not isHaveNextAttack and isFinalBlock then
|
||||
self.team:setCentralizedAttack(false)
|
||||
self.team:setIsFinalBlock(isFinalBlock)
|
||||
end
|
||||
|
||||
self:onSkillTakeEffect(self.currActiveSkill, isFinalBlock, self.validEffectIdx)
|
||||
if not isHaveNextAttack and isFinalBlock then
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
|
||||
local attackName = self.currActiveSkill:getSkillAttackName()
|
||||
self.currAttackKeyTime = self:getKeyFrameTime(self.currActiveSkill, self.currAttackBlockIndex + 1, attackName)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1220,21 +1232,22 @@ function BattleUnitComp:updateNormalAttack(dt)
|
||||
else
|
||||
if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用
|
||||
local skill = self.unitEntity:getNormalSkill()
|
||||
local isFinalBlock = skill and skill:isFinalBlock(self.currAttackBlockIndex) or false
|
||||
if self.normalSkillCount == 1 and isFinalBlock then -- 如果是最后一次攻击,那么敌人受到这次攻击可以开始嗝屁了
|
||||
self.team:setCentralizedAttack(false)
|
||||
self.team:setIsFinalBlock(isFinalBlock)
|
||||
end
|
||||
self:onSkillTakeEffect(skill, isFinalBlock, self.validEffectIdx)
|
||||
if self.normalSkillCount == 1 and isFinalBlock then -- 如果是最后一次攻击,那么可以开始跑血条了
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
|
||||
if skill then
|
||||
local attackName = skill:getSkillAttackName()
|
||||
self.currAttackKeyTime = self:getKeyFrameTime(skill, self.currAttackBlockIndex + 1, attackName)
|
||||
else
|
||||
self.currAttackKeyTime = 0
|
||||
end
|
||||
|
||||
local isFinalBlock = self.currAttackKeyTime <= 0
|
||||
if self.normalSkillCount == 1 and isFinalBlock then -- 如果是最后一次攻击,那么敌人受到这次攻击可以开始嗝屁了
|
||||
self.team:setCentralizedAttack(false)
|
||||
end
|
||||
self:onSkillTakeEffect(skill, isFinalBlock, self.validEffectIdx)
|
||||
if self.normalSkillCount == 1 and isFinalBlock then -- 如果是最后一次攻击,那么可以开始跑血条了
|
||||
self.battleController:setIsPauseHpProgress(false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1296,9 +1309,6 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
|
||||
if #effectList == 0 then
|
||||
return
|
||||
end
|
||||
if not validEffectIdx then
|
||||
validEffectIdx = {1, 1}
|
||||
end
|
||||
local targetType = skill:getTargetType()
|
||||
local target
|
||||
if targetType == 1 then -- 自己
|
||||
@ -1317,15 +1327,25 @@ function BattleUnitComp:onSkillTakeEffect(skill, isFinalBlock, validEffectIdx)
|
||||
end
|
||||
|
||||
local succ = false
|
||||
for k, effect in ipairs(effectList) do
|
||||
if k >= validEffectIdx[1] and k <= validEffectIdx[2] then
|
||||
if self:judgeSkillEffectCondition(skill, k) then
|
||||
local effectStartIdx = 1
|
||||
local effectEndIdx = 1
|
||||
if validEffectIdx then
|
||||
effectStartIdx = validEffectIdx[1] + 1
|
||||
effectEndIdx = validEffectIdx[2]
|
||||
end
|
||||
for i = effectStartIdx, effectEndIdx do
|
||||
local effect = effectList[i]
|
||||
if effect then
|
||||
if self:judgeSkillEffectCondition(skill, i) then
|
||||
if self:takeEffect(effect, target) then
|
||||
succ = true
|
||||
end
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if succ then
|
||||
if skill:getIsHurtType() then
|
||||
self.team:addCombo()
|
||||
@ -1565,7 +1585,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
end
|
||||
local hpPercent = self.unitEntity:getHpPercent()
|
||||
self.battleController:refreshHp(self.side, hp, hpPercent)
|
||||
if atker:getIsCentralizedAttack() then
|
||||
if not atker:getIsFinalBlock() then
|
||||
if damage < 0 then
|
||||
self:playHurt()
|
||||
end
|
||||
|
||||
@ -531,6 +531,18 @@ function BattleTeam:setCentralizedAttack(centralizedAttack)
|
||||
self.centralizedAttack = centralizedAttack
|
||||
end
|
||||
|
||||
function BattleTeam:setIsFinalBlock(isFinalBlock)
|
||||
Logger.logHighlight(isFinalBlock)
|
||||
if not self.isFinalBlock and not isFinalBlock then
|
||||
return
|
||||
end
|
||||
self.isFinalBlock = isFinalBlock
|
||||
end
|
||||
|
||||
function BattleTeam:getIsFinalBlock()
|
||||
return self.isFinalBlock
|
||||
end
|
||||
|
||||
function BattleTeam:addCombo()
|
||||
if self.side ~= BattleConst.SIDE_ATK then
|
||||
return
|
||||
|
||||
@ -275,19 +275,20 @@ function IdleUnitComp:getAnimationDuration(aniName)
|
||||
return duration or 0
|
||||
end
|
||||
|
||||
function IdleUnitComp:getAnimationKeyFrameTime(animationName)
|
||||
function IdleUnitComp:getAnimationKeyFrameTime(animationName, index)
|
||||
index = index or 1
|
||||
if self.attackKeyFrameTimeMap == nil then
|
||||
self.attackKeyFrameTimeMap = {}
|
||||
end
|
||||
local time = self.attackKeyFrameTimeMap[animationName]
|
||||
if time == nil then
|
||||
time = self.baseObject:getAnimationKeyFrameTime(animationName)
|
||||
if time <= 0 then -- 容错处理
|
||||
time = 0.3
|
||||
local timeList = self.attackKeyFrameTimeMap[animationName]
|
||||
if timeList == nil then
|
||||
local timeList = self.baseObject:getAnimationKeyFrameTimes(animationName)
|
||||
if not timeList[1] then
|
||||
table.insert(timeList, 0.3)
|
||||
end
|
||||
self.attackKeyFrameTimeMap[animationName] = time
|
||||
self.attackKeyFrameTimeMap[animationName] = timeList
|
||||
end
|
||||
return time
|
||||
return timeList[index] or 0.3
|
||||
end
|
||||
|
||||
function IdleUnitComp:getNormalSkill(reRandom)
|
||||
|
||||
@ -195,6 +195,10 @@ function BattleSkillEntity:getEffectBlock()
|
||||
return self.effectBlock
|
||||
end
|
||||
|
||||
function BattleSkillEntity:isFinalBlock(index)
|
||||
return self.effectBlock[index + 1] == nil
|
||||
end
|
||||
|
||||
function BattleSkillEntity:getEffectBlockTime()
|
||||
return self.blockTime
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user