bug修复

This commit is contained in:
xiekaidong 2023-06-05 18:24:06 +08:00
parent eb588d4e33
commit 0441e09d12
3 changed files with 39 additions and 12 deletions

View File

@ -471,6 +471,12 @@ function BattleUnitComp:removeShield(buffEffect)
end end
function BattleUnitComp:changeState(state) function BattleUnitComp:changeState(state)
if self.currState == UNIT_STATE.DEAD then -- 死亡后只能去死亡状态
if state ~= UNIT_STATE.DEAD then
return false
end
end
-- 进入目标状态 -- 进入目标状态
if state == UNIT_STATE.IDLE then -- idle为默认状态其状态下判定特殊状态 if state == UNIT_STATE.IDLE then -- idle为默认状态其状态下判定特殊状态
if self.unitEntity:getIsFrozen() then -- 有冰冻buff if self.unitEntity:getIsFrozen() then -- 有冰冻buff
@ -483,11 +489,7 @@ function BattleUnitComp:changeState(state)
if self.currState == state and not self:repeatCurrState() then if self.currState == state and not self:repeatCurrState() then
return false return false
end end
if self.currState == UNIT_STATE.DEAD then -- 死亡后只能去死亡状态
if state ~= UNIT_STATE.DEAD then
return false
end
end
-- 离开当前状态 -- 离开当前状态
if self.currState == UNIT_STATE.IDLE then if self.currState == UNIT_STATE.IDLE then
self:exitIdleState() self:exitIdleState()
@ -741,7 +743,7 @@ function BattleUnitComp:playBlock()
end 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.team:getMainUnitLocalPosition(self)
if self.side == BattleConst.SIDE_ATK then if self.side == BattleConst.SIDE_ATK then
direction = BattleConst.EFFECT_TYPE_MOVE_L direction = BattleConst.EFFECT_TYPE_MOVE_L
end end
@ -1561,7 +1563,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
self.team:handleShield(shieldHpDiff, self) self.team:handleShield(shieldHpDiff, self)
end end
local hp = self.unitEntity:getHp() local hp = self.unitEntity:getHp()
local x, y = self.baseObject:fastGetLocalPosition() local x, y = self.team:getMainUnitLocalPosition(self)
local damage = num local damage = num
if num < 0 then -- 伤害 if num < 0 then -- 伤害
local delayTime = 0 local delayTime = 0
@ -1638,7 +1640,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
self.battleController:refreshHp(self.side, hp, hpPercent) self.battleController:refreshHp(self.side, hp, hpPercent)
if not atker:getIsFinalBlock() or not self.battleController:getIsLastInstruction() then if not atker:getIsFinalBlock() or not self.battleController:getIsLastInstruction() then
if damage < 0 then if damage < 0 then
self:playHurt() self.team:playHurt()
end end
else else
if self.unitEntity:getIsDead() then if self.unitEntity:getIsDead() then
@ -1657,9 +1659,9 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
self.battleController:resetTimeSpeed(true) self.battleController:resetTimeSpeed(true)
self:changeState(UNIT_STATE.DEAD) self.team:changeDead() -- 因为buff生效对象有可能不是当前主英雄会导致状态不对所以使用主英雄来播放动画
elseif damage < 0 then elseif damage < 0 then
self:playHurt() self.team:playHurt()
end end
end end
@ -1671,7 +1673,11 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
end end
function BattleUnitComp:showEffectNumber(colorType, effectType, num, x, y, delayTime) function BattleUnitComp:showEffectNumber(colorType, effectType, num, x, y, delayTime)
local addY = BattleConst.MIN_NODE_HEIGHT[self.unitEntity:getBody()] or BattleConst.MIN_NODE_HEIGHT_DEFAULT local body = self.unitEntity:getBody()
if self.team:getMainUnit() then
body = self.team:getMainUnit().unitEntity:getBody()
end
local addY = BattleConst.MIN_NODE_HEIGHT[body] or BattleConst.MIN_NODE_HEIGHT_DEFAULT
self.battleController:showEffectNumber(colorType, effectType, num, x, y + addY, delayTime) self.battleController:showEffectNumber(colorType, effectType, num, x, y + addY, delayTime)
end end

View File

@ -260,7 +260,7 @@ function BattleControllerDailyChallenge:postWaveOver(atkDead, isQuit)
local duration = Time:getServerTime() - self.waveStartTime local duration = Time:getServerTime() - self.waveStartTime
local totalTime = Time:getServerTime() - self.battleStartTime local totalTime = Time:getServerTime() - self.battleStartTime
local startTimes = DataManager.DailyChallengeData:getTotalFightCount() local startTimes = DataManager.DailyChallengeData:getTotalFightCount()
local isFirstWin = false -- TODO local isFirstWin = false -- TODO 策划说不需要 因为系数在变
local isFianlStep = self.waveIndex >= self.maxWaveIndex local isFianlStep = self.waveIndex >= self.maxWaveIndex

View File

@ -166,6 +166,27 @@ function BattleTeam:changeMainUnit(matchType)
unit:playSwitchIn() unit:playSwitchIn()
end end
function BattleTeam:changeDead()
if not self.mainUnit then
return
end
self.mainUnit:changeState(BattleConst.UNIT_STATE.DEAD)
end
function BattleTeam:playHurt()
if not self.mainUnit then
return
end
self.mainUnit:playHurt()
end
function BattleTeam:getMainUnitLocalPosition(backup)
if not self.mainUnit then
return backup.baseObject:fastGetLocalPosition()
end
return self.mainUnit.baseObject:fastGetLocalPosition()
end
-- 回合结束的时候要结算buff和技能 -- 回合结束的时候要结算buff和技能
function BattleTeam:onRoundEnd() function BattleTeam:onRoundEnd()
for k, v in ipairs(self.unitList) do for k, v in ipairs(self.unitList) do