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