diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index b820c740..ff5d5c9c 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -236,7 +236,13 @@ function BattleUnitComp:getAnimationKeyFrameTime(animationName) return time end +function BattleUnitComp:getIsCentralizedAttack() + return self.centralizedAttack +end + function BattleUnitComp:beforeAttack() + self.centralizedAttack = true + self.battleController:setIsPauseHpProgress(true) self:checkPassiveEvent(PASSIVE_EVENT.ON_UNI_ATTACK_START, self) end @@ -279,18 +285,21 @@ function BattleUnitComp:useSkill(index, count, callback) self.actionOverCallback = nil self.activeSkillIndex = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() return end if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() end else if not self:changeState(UNIT_STATE.SKILL_ATTACK) then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() end end @@ -313,18 +322,21 @@ function BattleUnitComp:useAllSkills(callback) if self.normalSkillCount <= 0 then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() return end if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() end else if not self:changeState(UNIT_STATE.SKILL_ATTACK) then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() end end @@ -336,6 +348,7 @@ function BattleUnitComp:useNormalSkill(count, callback) if not self:changeState(UNIT_STATE.NORMAL_ATTACK) then self.actionOverCallback = nil self.battleController:setIsPauseHpProgress(false) + self.centralizedAttack = false callback() end end @@ -701,14 +714,21 @@ function BattleUnitComp:updateSkillAttack(dt) if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用 self.currAttackKeyTime = 0 if self.normalSkillCount > 0 then + if self.normalSkillCount == 1 and self.currActiveSkill == nil then -- 最后一次攻击 + self.centralizedAttack = false + end local skill = self.unitEntity:getNormalSkill() self:onSkillTakeEffect(skill) if self.normalSkillCount == 1 and self.currActiveSkill == nil then -- 最后一次攻击 self.battleController:setIsPauseHpProgress(false) end else + local isHaveNextAttack = self:getIsHaveNextAvailableActiveSkill() + if not isHaveNextAttack then + self.centralizedAttack = false + end self:onSkillTakeEffect(self.currActiveSkill) - if not self:getIsHaveNextAvailableActiveSkill() then + if not isHaveNextAttack then self.battleController:setIsPauseHpProgress(false) end end @@ -868,6 +888,9 @@ function BattleUnitComp:updateNormalAttack(dt) else if self.currAttackKeyTime > 0 and self.attackTime >= self.currAttackKeyTime then -- 到达关键后使用 self.currAttackKeyTime = 0 + if self.normalSkillCount == 1 then -- 如果是最后一次攻击,那么敌人受到这次攻击可以开始嗝屁了 + self.centralizedAttack = false + end local skill = self.unitEntity:getNormalSkill() self:onSkillTakeEffect(skill) if self.normalSkillCount == 1 then -- 如果是最后一次攻击,那么可以开始跑血条了 @@ -966,6 +989,12 @@ function BattleUnitComp:removeEffect(buff, target) end function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectStatus) + if self:getIsClear() then + return 0 + end + if self.currState == UNIT_STATE.DEAD then + return 0 + end if num == 0 then return 0 end @@ -986,9 +1015,16 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta local hp = self.unitEntity:getHp() local hpPercent = self.unitEntity:getHpPercent() self.battleController:refreshHp(self.side, hp, hpPercent) - - if self.currState == UNIT_STATE.IDLE then - self:playHurt() + if atker:getIsCentralizedAttack() then + if self.currState == UNIT_STATE.IDLE then + self:playHurt() + end + else + if self.unitEntity:getIsDead() then + self:changeState(UNIT_STATE.DEAD) + elseif self.currState == UNIT_STATE.IDLE then + self:playHurt() + end end if hp > 0 then self:checkPassiveEvent(PASSIVE_EVENT.HP_LOWER_THAN, atker, hpPercent) @@ -1001,7 +1037,11 @@ end function BattleUnitComp:playDead(callback) self.deadOverCallback = callback - if not self:changeState(UNIT_STATE.DEAD) then + if self:getIsClear() then + self.deadOverCallback = nil + return callback() + end + if self.currState ~= UNIT_STATE.DEAD and not self:changeState(UNIT_STATE.DEAD) then self.deadOverCallback = nil callback() end diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 3d7025fd..276468be 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -58,7 +58,6 @@ function BattleTeam:useNormalSkill(matchType, count, callback) return callback() end self.mainUnit = unit - self.battleController:setIsPauseHpProgress(true) unit:beforeAttack() unit:resetBeforeAttack() unit:useNormalSkill(count, callback) @@ -78,7 +77,6 @@ function BattleTeam:useSkill(matchType, count, callback) return callback() end self.mainUnit = unit - self.battleController:setIsPauseHpProgress(true) unit:beforeAttack() unit:resetBeforeAttack() unit:useSkill(1, count, callback) @@ -121,7 +119,6 @@ function BattleTeam:mainUnitUseAllSkills(callback) if self.mainUnit:getIsLimit() then return callback() end - self.battleController:setIsPauseHpProgress(true) self.mainUnit:beforeAttack() self.mainUnit:resetBeforeAttack() self.mainUnit:useAllSkills(callback) diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua b/lua/app/userdata/battle/team/battle_unit_entity.lua index bd606824..51b8e877 100644 --- a/lua/app/userdata/battle/team/battle_unit_entity.lua +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua @@ -249,6 +249,10 @@ function BattleUnitEntity:getExp() return self.unitData.exp end +function BattleUnitEntity:getIsDead() + return self.team:getIsDead() +end + function BattleUnitEntity:addSkillExtraUseTimes(skillId, count) if self.skillExtraUseTimes == nil then self.skillExtraUseTimes = {}