diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 8c7c82d8..6f128b9c 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -93,6 +93,7 @@ BattleConst.SPINE_ANIMATION_NAME = { ATTACK = "atk1", MOVE = "move", HIT = "hit", + DEAD = "die", } BattleConst.EFFECT_TYPE = { diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index ecc71393..8c8d3743 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -30,8 +30,8 @@ end function BattleUnitComp:_initBase() self.isClear = false - self.isDead = false self.isMove = false + self.deadTime = 0 self.attackTime = 0 self.currAttackDuration = 0 self.currAttackKeyTime = 0 @@ -103,7 +103,7 @@ function BattleUnitComp:changeState(state) if self.currState == state and not self:repeatCurrState() then return false end - if self.isDead then -- 死亡后只能去死亡状态 + if self.currState == UNIT_STATE.DEAD then -- 死亡后只能去死亡状态 if state ~= UNIT_STATE.DEAD then return false end @@ -147,6 +147,27 @@ function BattleUnitComp:repeatCurrState() return false end +function BattleUnitComp:updateDead(dt) + self.deadTime = self.deadTime - dt + if self.deadTime <= 0 then + self:clear() + if self.deadOverCallback then + local callback = self.deadOverCallback + self.deadOverCallback = nil + callback() + end + end +end + +function BattleUnitComp:exitDeadState() +end + +function BattleUnitComp:enterDeadState() + local aniName = SPINE_ANIMATION_NAME.DEAD + self.deadTime = self:getAnimationDuration(aniName) + 0.1 + self:playAnimation(aniName, false, false) +end + function BattleUnitComp:exitIdleState() end @@ -376,11 +397,19 @@ function BattleUnitComp:showEffectNumber(num, x, y) self.battleController:showEffectNumber(num, x, y) end +function BattleUnitComp:playDead(callback) + self.deadOverCallback = callback + if not self:changeState(UNIT_STATE.DEAD) then + self.deadOverCallback = nil + callback() + end +end + function BattleUnitComp:tick(dt) if self.isClear then return end - if self.isDead then + if self.currState == UNIT_STATE.DEAD then self:updateDead(dt) return end @@ -395,4 +424,15 @@ function BattleUnitComp:tick(dt) end end +function BattleUnitComp:getIsClear() + return self.isClear +end + +function BattleUnitComp:clear() + if self.isClear then + return + end + self.isClear = true +end + return BattleUnitComp \ No newline at end of file diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 04d0b400..4d42595a 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -53,6 +53,9 @@ function BattleController:initDefUnits(callback) callback() end +function BattleController:findNextDefUnit() +end + function BattleController:tick(dt) end @@ -133,6 +136,7 @@ function BattleController:init(params) self.battleData:init() BattleScheduler:init() BattleHelper:init() + self:initOther() self:prepareFight() end @@ -276,7 +280,7 @@ function BattleController:enterAtkStepOver() local defTeam = self.battleData:getDefTeam() if not defTeam or defTeam:getIsDead() then -- 怪物死了, 直接进入刷新逻辑 - self:enterRefreshBoard() + self:findNextDefUnit() return end diff --git a/lua/app/module/battle/controller/battle_controller_stage.lua b/lua/app/module/battle/controller/battle_controller_stage.lua index 7eb46595..7d0929d6 100644 --- a/lua/app/module/battle/controller/battle_controller_stage.lua +++ b/lua/app/module/battle/controller/battle_controller_stage.lua @@ -13,6 +13,10 @@ function BattleControllerStage:getMaxWave() return #chapterInfo.monster end +function BattleController:initOther() + +end + function BattleControllerStage:initDefUnits(callback) local config = ConfigManager:getConfig("chapter")[self.chapterId] local unitEntity = DataManager.BattleData:addMonster(config.monster[1]) @@ -74,6 +78,10 @@ function BattleControllerStage:getNotInvolvedSkills() return self.notInvolvedSkills end +function BattleControllerStage:findNextDefUnit() + +end + function BattleControllerStage:controllBattleEnd() end