换人逻辑
This commit is contained in:
parent
2d3991fcbd
commit
a8d3e443cd
@ -60,6 +60,8 @@ BattleConst.UNIT_STATE = {
|
||||
HURT = 4, -- 受伤
|
||||
DEAD = 5, -- 死亡
|
||||
ENTER_BATTLEFIELD = 6, -- 进入战场
|
||||
SWITCH_IN = 7, -- 入场
|
||||
SWITCH_OUT = 8, -- 离场
|
||||
}
|
||||
|
||||
BattleConst.MATCH_DMG_ADDITION_NAME = {
|
||||
@ -95,6 +97,8 @@ BattleConst.SPINE_ANIMATION_NAME = {
|
||||
MOVE = "move",
|
||||
HIT = "suffer",
|
||||
DEAD = "death",
|
||||
BORN = "born",
|
||||
OUT = "out",
|
||||
}
|
||||
|
||||
BattleConst.EFFECT_TYPE = {
|
||||
|
||||
@ -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
|
||||
@ -43,6 +52,7 @@ function BattleUnitComp:_initBase()
|
||||
self.attackTime = 0
|
||||
self.currAttackDuration = 0
|
||||
self.currAttackKeyTime = 0
|
||||
self.switchTime = 0
|
||||
self.isPlayHurt = 0
|
||||
self.attackDurationMap = {}
|
||||
self.buffList = {}
|
||||
@ -160,6 +170,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
|
||||
@ -175,6 +189,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
|
||||
@ -188,6 +206,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
|
||||
@ -620,6 +672,10 @@ function BattleUnitComp:tick(dt)
|
||||
self:updateSkillAttack(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
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ function BattleController:onLinkChange()
|
||||
|
||||
self.battleUI:refreshSkill(elementTypeMap)
|
||||
if mainElementType then
|
||||
Logger.logHighlight("mainElementType " .. mainElementType)
|
||||
self.atkTeam:changeMainUnit(mainElementType)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1166,12 +1166,10 @@ function BattleController:snapshotBoard()
|
||||
return snapshot
|
||||
end
|
||||
|
||||
function BattleController:addBattleExp(side, exp)
|
||||
if side ~= BattleConst.SIDE_ATK or not self.battleData then
|
||||
function BattleController:addBattleExp(exp)
|
||||
if not self.battleData or not exp then
|
||||
return
|
||||
end
|
||||
|
||||
exp = exp or 1
|
||||
self.battleData:addExp(exp)
|
||||
end
|
||||
|
||||
@ -1225,11 +1223,12 @@ local function _addCurRoundAttr(self, instruction, callback)
|
||||
end
|
||||
|
||||
local function _assisting(self, instruction, callback)
|
||||
self:addBattleExp(BattleConst.SIDE_ATK, instruction.count) -- 先直接加
|
||||
self:addBattleExp(instruction.count)
|
||||
callback()
|
||||
end
|
||||
|
||||
local function _generalAttack(self, instruction, callback)
|
||||
self:addBattleExp(instruction.count) -- 先直接加
|
||||
self.atkTeam:useNormalSkill(instruction.skillMatch, instruction.count, callback)
|
||||
end
|
||||
|
||||
|
||||
@ -62,6 +62,19 @@ function BattleTeam:mainUnitUseAllSkills(callback)
|
||||
self.mainUnit:useAllSkills(callback)
|
||||
end
|
||||
|
||||
function BattleTeam:changeMainUnit(matchType)
|
||||
if self.mainUnit and matchType == self.mainUnit:getMatchType() then
|
||||
return
|
||||
end
|
||||
local unit = self.unitMap[matchType]
|
||||
if unit == nil then
|
||||
return
|
||||
end
|
||||
self.mainUnit:playSwitchOut()
|
||||
self.mainUnit = unit
|
||||
unit:playSwitchIn()
|
||||
end
|
||||
|
||||
function BattleTeam:tick(dt)
|
||||
for k, v in ipairs(self.unitList) do
|
||||
v:tick(dt)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user