.
This commit is contained in:
parent
9305845ef9
commit
caa8c1e801
@ -28,6 +28,15 @@ function BattleUnitComp:playBorn()
|
||||
self:changeState(UNIT_STATE.IDLE)
|
||||
end
|
||||
|
||||
function BattleUnitComp:playSwitchIn()
|
||||
self:changeState(UNIT_STATE.SWITCH_IN)
|
||||
end
|
||||
|
||||
function BattleUnitComp:playSwitchOut()
|
||||
self:changeState(UNIT_STATE.SWITCH_OUT)
|
||||
end
|
||||
|
||||
|
||||
function BattleUnitComp:getModelId()
|
||||
return self.modelId
|
||||
end
|
||||
@ -47,6 +56,7 @@ function BattleUnitComp:_initBase()
|
||||
self.attackTime = 0
|
||||
self.currAttackDuration = 0
|
||||
self.currAttackKeyTime = 0
|
||||
self.switchTime = 0
|
||||
self.isPlayHurt = 0
|
||||
self.attackDurationMap = {}
|
||||
self.shieldBuffList = {}
|
||||
@ -204,6 +214,10 @@ function BattleUnitComp:changeState(state)
|
||||
self:exitDeadState()
|
||||
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
|
||||
self:exitEnterBattlefieldState()
|
||||
elseif self.currState == UNIT_STATE.SWITCH_IN then
|
||||
self:exitSwitchInState()
|
||||
elseif self.currState == UNIT_STATE.SWITCH_OUT then
|
||||
self:exitSwitchOutState()
|
||||
end
|
||||
-- 进入目标状态
|
||||
self.currState = state
|
||||
@ -221,6 +235,10 @@ function BattleUnitComp:changeState(state)
|
||||
self:enterBornState()
|
||||
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
|
||||
self:enterEnterBattlefieldState()
|
||||
elseif self.currState == UNIT_STATE.SWITCH_IN then
|
||||
self:enterSwitchInState()
|
||||
elseif self.currState == UNIT_STATE.SWITCH_OUT then
|
||||
self:enterSwitchOutState()
|
||||
end
|
||||
return true
|
||||
end
|
||||
@ -234,6 +252,40 @@ function BattleUnitComp:repeatCurrState()
|
||||
return false
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateSwitchInState(dt)
|
||||
self.switchTime = self.switchTime - dt
|
||||
if self.switchTime < 0 then
|
||||
self:changeState(UNIT_STATE.IDLE)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterSwitchInState()
|
||||
local aniName = SPINE_ANIMATION_NAME.BORN
|
||||
self.switchTime = self:getAnimationDuration(aniName) + 0.1
|
||||
self:initPosition()
|
||||
self:playAnimation(aniName, false, true)
|
||||
end
|
||||
|
||||
function BattleUnitComp:exitSwitchInState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateSwitchOutState(dt)
|
||||
self.switchTime = self.switchTime - dt
|
||||
if self.switchTime < 0 then
|
||||
self:changeState(UNIT_STATE.IDLE)
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterSwitchOutState()
|
||||
local aniName = SPINE_ANIMATION_NAME.OUT
|
||||
self.switchTime = self:getAnimationDuration(aniName) + 0.1
|
||||
self:playAnimation(aniName, false, true)
|
||||
end
|
||||
|
||||
function BattleUnitComp:exitSwitchOutState()
|
||||
self:hideOutsideScreen()
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateDead(dt)
|
||||
self.deadTime = self.deadTime - dt
|
||||
if self.deadTime <= 0 then
|
||||
@ -669,9 +721,9 @@ function BattleUnitComp:takeDamageOrCure(atker, buff, num, effectType, effectSta
|
||||
if num == 0 then
|
||||
return 0
|
||||
end
|
||||
local shieldHpBefore = self.unitEntity:getShield()
|
||||
local shieldHpBefore = self.unitEntity:getShieldHp()
|
||||
self.unitEntity:takeDamageOrCure(num)
|
||||
local shieldHpDiff = self.unitEntity:getShield() - shieldHpBefore
|
||||
local shieldHpDiff = self.unitEntity:getShieldHp() - shieldHpBefore
|
||||
if shieldHpDiff < 0 then -- 说明护盾减少了
|
||||
self:handleShield(shieldHpDiff, self)
|
||||
end
|
||||
@ -729,6 +781,10 @@ function BattleUnitComp:tick(dt)
|
||||
self:updateAssistingAttackState(dt)
|
||||
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
|
||||
self:updateEnterBattlefieldState(dt)
|
||||
elseif self.currState == UNIT_STATE.SWITCH_IN then
|
||||
self:updateSwitchInState(dt)
|
||||
elseif self.currState == UNIT_STATE.SWITCH_OUT then
|
||||
self:updateSwitchOutState(dt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user