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