冰冻状态、昏睡状态
This commit is contained in:
parent
fb0ebff007
commit
e5bcfa3f09
@ -124,6 +124,8 @@ BattleConst.UNIT_STATE = {
|
||||
ASSISTING_ATTACK = 8, -- 协助攻击
|
||||
WAIT = 9, -- 等待
|
||||
RECOVER_HP_WAVE = 10, -- 波次之间回血
|
||||
FROZEN = 11, -- 冻结状态
|
||||
VERITGO = 12, -- 昏睡
|
||||
}
|
||||
|
||||
BattleConst.MATCH_DMG_ADDITION_NAME = {
|
||||
@ -177,10 +179,13 @@ BattleConst.SPINE_ANIMATION_NAME = {
|
||||
ATTACK = "attack01",
|
||||
MOVE = "move",
|
||||
HIT = "suffer",
|
||||
HIT_2 = "suffer02",
|
||||
DEAD = "death",
|
||||
BORN = "born",
|
||||
OUT = "out",
|
||||
BLOCK = "block",
|
||||
FROZEN = "frozen",
|
||||
VERTIGO = "vertigo",
|
||||
}
|
||||
|
||||
BattleConst.EFFECT_TYPE = {
|
||||
|
||||
@ -15,6 +15,8 @@ local PASSIVE_EVENT = BattleConst.PASSIVE_EVENT
|
||||
local HURT_STATE_CRIT = BattleConst.HURT_STATE_CRIT
|
||||
local EFFECT_TYPE = BattleConst.EFFECT_TYPE
|
||||
local TIME_FACTOR = BattleConst.TIME_FACTOR
|
||||
local HURT_ANI_NAME_LIST = {SPINE_ANIMATION_NAME.HIT, SPINE_ANIMATION_NAME.HIT_2}
|
||||
local HURT_ANI_NAME_LIST_COUNT = 2
|
||||
|
||||
function BattleUnitComp:ctor()
|
||||
end
|
||||
@ -86,7 +88,8 @@ function BattleUnitComp:_initBase()
|
||||
self.currAttackBlockIndex = 0 -- 多段伤害索引
|
||||
self.validEffectIdx = {}
|
||||
self.switchTime = 0
|
||||
self.playIdleSubAniDuration = {}
|
||||
self.isPlayingSubAni = false
|
||||
self.playSubAniDuration = {}
|
||||
self.attackDurationMap = {}
|
||||
self.attackKeyFrameTimeMap = {}
|
||||
self.shieldBuffList = {}
|
||||
@ -227,6 +230,9 @@ function BattleUnitComp:stopRunAction()
|
||||
end
|
||||
|
||||
function BattleUnitComp:playAnimation(name, loop, forceRefresh)
|
||||
if name == SPINE_ANIMATION_NAME.HIT or name == SPINE_ANIMATION_NAME.BLOCK then
|
||||
self.isPlayingSubAni = true
|
||||
end
|
||||
self.currAnimationName = name
|
||||
self.baseObject:playAnimation(name, loop, forceRefresh)
|
||||
end
|
||||
@ -443,6 +449,15 @@ function BattleUnitComp:removeShield(buffEffect)
|
||||
end
|
||||
|
||||
function BattleUnitComp:changeState(state)
|
||||
-- 进入目标状态
|
||||
if state == UNIT_STATE.IDLE then -- idle为默认状态,其状态下判定特殊状态
|
||||
if self.unitEntity:getIsFrozen() then -- 有冰冻buff
|
||||
state = UNIT_STATE.FROZEN
|
||||
elseif self.unitEntity:getIsLethargy() or self.unitEntity:getIsStun() then
|
||||
state = UNIT_STATE.VERITGO
|
||||
end
|
||||
end
|
||||
|
||||
if self.currState == state and not self:repeatCurrState() then
|
||||
return false
|
||||
end
|
||||
@ -472,9 +487,14 @@ function BattleUnitComp:changeState(state)
|
||||
self:exitWaitState()
|
||||
elseif self.currState == UNIT_STATE.RECOVER_HP_WAVE then
|
||||
self:exitRecoverHpWaveState()
|
||||
elseif self.currState == UNIT_STATE.FROZEN then
|
||||
self:exitFrozenState()
|
||||
elseif self.currState == UNIT_STATE.VERITGO then
|
||||
self:exitVeritgoState()
|
||||
end
|
||||
-- 进入目标状态
|
||||
|
||||
self.currState = state
|
||||
|
||||
if state == UNIT_STATE.IDLE then
|
||||
self:enterIdleState()
|
||||
elseif state == UNIT_STATE.NORMAL_ATTACK then
|
||||
@ -495,6 +515,10 @@ function BattleUnitComp:changeState(state)
|
||||
self:enterWaitState()
|
||||
elseif state == UNIT_STATE.RECOVER_HP_WAVE then
|
||||
self:enterRecoverHpWaveState()
|
||||
elseif state == UNIT_STATE.FROZEN then
|
||||
self:enterFrozenState()
|
||||
elseif state == UNIT_STATE.VERITGO then
|
||||
self:enterVeritgoState()
|
||||
end
|
||||
return true
|
||||
end
|
||||
@ -646,11 +670,11 @@ function BattleUnitComp:enterIdleState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateIdle(dt)
|
||||
self:updateIdleSubAni(dt)
|
||||
self:updateIdleSubAni(dt, SPINE_ANIMATION_NAME.IDLE)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateIdleSubAni(...)
|
||||
if not self.currAnimationName then
|
||||
if not self.currAnimationName or not self.isPlayingSubAni then
|
||||
return
|
||||
end
|
||||
if self.currAnimationName == SPINE_ANIMATION_NAME.HIT then
|
||||
@ -661,28 +685,35 @@ function BattleUnitComp:updateIdleSubAni(...)
|
||||
end
|
||||
|
||||
function BattleUnitComp:playHurt()
|
||||
local name = SPINE_ANIMATION_NAME.HIT
|
||||
self.playIdleSubAniTime = 0
|
||||
if self.playIdleSubAniDuration[name] == nil then
|
||||
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
if self.currState == UNIT_STATE.IDLE or
|
||||
self.currState == UNIT_STATE.VERITGO then
|
||||
local name = HURT_ANI_NAME_LIST[math.random(1, HURT_ANI_NAME_LIST_COUNT)]
|
||||
self.playSubAniTime = 0
|
||||
self.curHurtName = name
|
||||
if self.playSubAniDuration[name] == nil then
|
||||
self.playSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
end
|
||||
self:playAnimation(name, false, false)
|
||||
end
|
||||
self:playAnimation(name, false, false)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateHurt(dt)
|
||||
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
|
||||
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.HIT] then
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||
function BattleUnitComp:updateHurt(dt, overAniName)
|
||||
self.playSubAniTime = self.playSubAniTime + dt
|
||||
if self.playSubAniTime >= self.playSubAniDuration[self.curHurtName or SPINE_ANIMATION_NAME.HIT] then
|
||||
self:playAnimation(overAniName, true, false)
|
||||
self.isPlayingSubAni = false
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:playBlock()
|
||||
local name = SPINE_ANIMATION_NAME.BLOCK
|
||||
self.playIdleSubAniTime = 0
|
||||
if self.playIdleSubAniDuration[name] == nil then
|
||||
self.playIdleSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
if self.currState == UNIT_STATE.IDLE then
|
||||
local name = SPINE_ANIMATION_NAME.BLOCK
|
||||
self.playSubAniTime = 0
|
||||
if self.playSubAniDuration[name] == nil then
|
||||
self.playSubAniDuration[name] = self:getAnimationDuration(name)
|
||||
end
|
||||
self:playAnimation(name, false, false)
|
||||
end
|
||||
self:playAnimation(name, false, false)
|
||||
|
||||
local direction = BattleConst.EFFECT_TYPE_MOVE_R
|
||||
local x, y = self.baseObject:fastGetLocalPosition()
|
||||
@ -694,13 +725,36 @@ function BattleUnitComp:playBlock()
|
||||
end
|
||||
|
||||
|
||||
function BattleUnitComp:updateBlock(dt)
|
||||
self.playIdleSubAniTime = self.playIdleSubAniTime + dt
|
||||
if self.playIdleSubAniTime >= self.playIdleSubAniDuration[SPINE_ANIMATION_NAME.BLOCK] then
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||
function BattleUnitComp:updateBlock(dt, overAniName)
|
||||
self.playSubAniTime = self.playSubAniTime + dt
|
||||
if self.playSubAniTime >= self.playSubAniDuration[SPINE_ANIMATION_NAME.BLOCK] then
|
||||
self:playAnimation(overAniName, true, false)
|
||||
self.isPlayingSubAni = false
|
||||
end
|
||||
end
|
||||
|
||||
function BattleUnitComp:exitFrozenState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterFrozenState()
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.FROZEN, true, false)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateFrozen(dt)
|
||||
self:updateIdleSubAni(dt, SPINE_ANIMATION_NAME.FROZEN)
|
||||
end
|
||||
|
||||
function BattleUnitComp:exitVeritgoState()
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterVeritgoState()
|
||||
self:playAnimation(SPINE_ANIMATION_NAME.VERTIGO, true, false)
|
||||
end
|
||||
|
||||
function BattleUnitComp:updateVeritgo(dt)
|
||||
self:updateIdleSubAni(dt, SPINE_ANIMATION_NAME.VERTIGO)
|
||||
end
|
||||
|
||||
function BattleUnitComp:enterRecoverHpWaveState()
|
||||
self.recoverHpCount = BattleConst.RECOVER_HP_COUNT
|
||||
self.recoverHpTime = BattleConst.RECOVER_HP_INTERVAL / 2
|
||||
@ -1482,7 +1536,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
local hpPercent = self.unitEntity:getHpPercent()
|
||||
self.battleController:refreshHp(self.side, hp, hpPercent)
|
||||
if atker:getIsCentralizedAttack() then
|
||||
if damage < 0 and self.currState == UNIT_STATE.IDLE then
|
||||
if damage < 0 then
|
||||
self:playHurt()
|
||||
end
|
||||
else
|
||||
@ -1492,7 +1546,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
|
||||
local target = self.battleController:getOtherSideMainUnit(self.side)
|
||||
target:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN, target)
|
||||
end
|
||||
elseif damage < 0 and self.currState == UNIT_STATE.IDLE then
|
||||
elseif damage < 0 then
|
||||
self:playHurt()
|
||||
end
|
||||
end
|
||||
@ -1712,6 +1766,10 @@ function BattleUnitComp:tick(dt)
|
||||
self:updateWaitState(dt)
|
||||
elseif self.currState == UNIT_STATE.RECOVER_HP_WAVE then
|
||||
self:updateRecoverHpWaveState(dt)
|
||||
elseif self.currState == UNIT_STATE.FROZEN then
|
||||
self:updateFrozen(dt)
|
||||
elseif self.currState == UNIT_STATE.VERITGO then
|
||||
self:updateVeritgo(dt)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -173,6 +173,7 @@ function BattleTeam:onRoundEnd()
|
||||
end
|
||||
self:doBuffWork()
|
||||
self.comboCount = 0
|
||||
self:getMainUnit():changeState(BattleConst.UNIT_STATE.IDLE)
|
||||
end
|
||||
|
||||
function BattleTeam:addShield(buffEffect)
|
||||
|
||||
@ -273,6 +273,10 @@ function BattleTeamEntity:removeActiveSkillLimit(name)
|
||||
self.activeSkillLimit = self.activeSkillLimit - 1
|
||||
end
|
||||
|
||||
function BattleTeamEntity:getIsStun()
|
||||
return self.stunCount > 0
|
||||
end
|
||||
|
||||
function BattleTeamEntity:getIsLethargy()
|
||||
return self.lethargyCount > 0
|
||||
end
|
||||
|
||||
@ -354,6 +354,10 @@ function BattleUnitEntity:removeActiveSkillLimit(name)
|
||||
self.team:removeActiveSkillLimit(name)
|
||||
end
|
||||
|
||||
function BattleUnitEntity:getIsStun()
|
||||
return self.team:getIsStun()
|
||||
end
|
||||
|
||||
function BattleUnitEntity:getIsLethargy()
|
||||
return self.team:getIsLethargy()
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user