伤害数字重叠问题

This commit is contained in:
xiekaidong 2023-06-14 18:35:20 +08:00
parent 47d8b479f9
commit 5214dd8136
2 changed files with 27 additions and 3 deletions

View File

@ -53,6 +53,7 @@ BattleConst.SKILL_ELIMINATION_TIME = 0.5
BattleConst.ELIMINATION_INTERVAL = 0.01 BattleConst.ELIMINATION_INTERVAL = 0.01
BattleConst.GRID_BREAK_EFFECT_INTERVAL = 0.1 BattleConst.GRID_BREAK_EFFECT_INTERVAL = 0.1
BattleConst.COMBO_DEFAULT_POSITION = 0 BattleConst.COMBO_DEFAULT_POSITION = 0
BattleConst.EFFECT_NUMBER_INTERVAL = 0.2
BattleConst.BATTLE_ROUND_STEP = { BattleConst.BATTLE_ROUND_STEP = {
WAIT_BEGIN = 0, -- 等待开始 WAIT_BEGIN = 0, -- 等待开始

View File

@ -1315,7 +1315,16 @@ function BattleUnitComp:addBuff(buffEffect, conditionResult)
x = x - 80 x = x - 80
end end
y = y - 120 y = y - 120
self:showEffectNumber(BattleConst.EFFECT_COLOR_SPECIAL, direction, buffEffect.buff:getShowName(true), x - 20, y - 20, 0, conditionResult == BattleConst.SKILL_CONDITION_RESULT.CONDITION_PASS) local time = Time:getServerTime()
if self.lastAddBuffTime == time then
self.lastSameTimeAddBuffCount = self.lastSameTimeAddBuffCount + 1
else
self.lastAddBuffTime = time
self.lastSameTimeAddBuffCount = 0
end
time = self.lastSameTimeAddBuffCount * BattleConst.EFFECT_NUMBER_INTERVAL
local showCombo = conditionResult == BattleConst.SKILL_CONDITION_RESULT.CONDITION_PASS
self:showEffectNumber(BattleConst.EFFECT_COLOR_SPECIAL, direction, buffEffect.buff:getShowName(true), x - 20, y - 20, time, showCombo)
end end
return self.team:addBuff(buffEffect) return self.team:addBuff(buffEffect)
@ -1604,11 +1613,19 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
local hp = self.unitEntity:getHp() local hp = self.unitEntity:getHp()
local x, y = self.team:getMainUnitLocalPosition(self) local x, y = self.team:getMainUnitLocalPosition(self)
local damage = num local damage = num
local time = Time:getServerTime()
if num < 0 then -- 伤害 if num < 0 then -- 伤害
local delayTime = 0 local delayTime = 0
if shieldHpDiff < 0 then if shieldHpDiff < 0 then
damage = damage - shieldHpDiff damage = damage - shieldHpDiff
delayTime = BattleConst.EFFECT_NUMBER_DELAY delayTime = BattleConst.EFFECT_NUMBER_DELAY
if self.lastBlueNumberTime == time then
self.lastSameTimeBlueCount = self.lastSameTimeBlueCount + 1
else
self.lastBlueNumberTime = time
self.lastSameTimeBlueCount = 0
end
delayTime = delayTime + self.lastSameTimeBlueCount * BattleConst.EFFECT_NUMBER_INTERVAL
if self.side == BattleConst.SIDE_ATK then if self.side == BattleConst.SIDE_ATK then
self:showEffectNumber(BattleConst.EFFECT_COLOR_BLUE, BattleConst.EFFECT_TYPE_MOVE_L, shieldHpDiff, x, y, 0, showHurtCombo) self:showEffectNumber(BattleConst.EFFECT_COLOR_BLUE, BattleConst.EFFECT_TYPE_MOVE_L, shieldHpDiff, x, y, 0, showHurtCombo)
else else
@ -1616,6 +1633,13 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
end end
end end
if damage < 0 then if damage < 0 then
if self.lastBlueNumberTime == time then
self.lastSameTimeBlueCount = self.lastSameTimeBlueCount + 1
else
self.lastBlueNumberTime = time
self.lastSameTimeBlueCount = 0
end
delayTime = delayTime + self.lastSameTimeBlueCount * BattleConst.EFFECT_NUMBER_INTERVAL
if effectStatus == HURT_STATE_CRIT then if effectStatus == HURT_STATE_CRIT then
self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_CRIT, "c" .. damage, x, y, delayTime, showHurtCombo) self:showEffectNumber(BattleConst.EFFECT_COLOR_RED, BattleConst.EFFECT_TYPE_CRIT, "c" .. damage, x, y, delayTime, showHurtCombo)
else else
@ -1665,14 +1689,13 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
end end
end end
elseif num > 0 then -- 治疗 elseif num > 0 then -- 治疗
local time = Time:getServerTime()
if self.lastHealTime == time then if self.lastHealTime == time then
self.lastSameTimeHealCount = self.lastSameTimeHealCount + 1 self.lastSameTimeHealCount = self.lastSameTimeHealCount + 1
else else
self.lastHealTime = time self.lastHealTime = time
self.lastSameTimeHealCount = 0 self.lastSameTimeHealCount = 0
end end
local delayTime = self.lastSameTimeHealCount * 0.1 local delayTime = self.lastSameTimeHealCount * BattleConst.EFFECT_NUMBER_INTERVAL
self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, delayTime) self:showEffectNumber(BattleConst.EFFECT_COLOR_GREEN, BattleConst.EFFECT_TYPE_BUFF, "+" .. num, x, y, delayTime)
end end
local hpPercent = self.unitEntity:getHpPercent() local hpPercent = self.unitEntity:getHpPercent()