【战斗】伤害数字延时显示

dev_chengFeng
gaoxin 2021-11-12 11:59:40 +08:00
parent cdb02f6142
commit 451d8f4460
3 changed files with 119 additions and 63 deletions

View File

@ -815,6 +815,7 @@ function this.GetSkillCombat(id)
BeforeBullet = combat.BeforeBullet,
SkillNumber = combat.SkillNumber,
SkillDuration = combat.SkillDuration,
DamageDelay = combat.DamageDelay,
BeforeOrientation = combat.BeforeOrientation,
Orientation = combat.Orientation,
HitOrientation = combat.HitOrientation,

View File

@ -417,10 +417,16 @@ local DotTypeTip = {
}
--
function EnemyView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
if skill and skill.continueTime > 0 and skill.attackCount > 1 then
local space = skill.continueTime / skill.attackCount
local count = skill.attackCount
local d = math.floor(dmg/count)
if skill then
-- 技能配置
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
local combat = BattleManager.GetSkillCombat(combatId)
--
local delay = combat.DamageDelay or 0
local continue = skill.continueTime or 0
local count = skill.attackCount or 1
local space = continue / count
local d = math.floor(dmg / count)
-- 如果平均伤害小于0 则
if d == 0 then
d = dmg
@ -429,22 +435,36 @@ function EnemyView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType,
if BattleManager.IsBattleTestPanel() then
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s, 伤害段数:%s每段伤害%s", self.camp, self.role.position, dmg, count, d))
end
if count ~= 1 then
-- 后续伤害延迟打出
self:LoopFunc(space, count - 1, function()
self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
end)
-- 立刻打出第一次伤害
local fd = dmg - d *(count - 1)
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
else
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
end
-- 伤害文字延时,有些受击特效不是立刻播放文字
self:DelayFunc(delay/1000, function()
-- 伤害文字
if count ~= 1 then
-- 多段伤害
-- 后续伤害延迟打出
self:LoopFunc(space, count - 1, function()
self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
end)
-- 立刻打出第一次伤害
local fd = dmg - d *(count - 1)
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect(continue)
else
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect()
end
end)
-- 播放特效
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
else
if BattleManager.IsBattleTestPanel() then
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s", self.camp, self.role.position, dmg))
end
-- 伤害文字
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect()
end
end
--
@ -476,26 +496,35 @@ function EnemyView:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotTyp
end
end
end
self.RoleLiveGOTran:DOShakeAnchorPos(0.3, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
self.RoleLiveGO.transform.anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2] )
end)
self.RoleLiveGOGraphic:DOColor(Color.New(1,0,0,1), 0.3):OnComplete(function ()
self.RoleLiveGOGraphic:DOColor(Color.New(1,1,1,1), 0.1)
end)
-- 受击放大1.2倍
self:DoScale(1.2, 0.3, function()
self:DoScale(1, 0.1)
end)
-- 播放受击动画
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
-- bo
if skill then
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
local combat = BattleManager.GetSkillCombat(combatId)
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
end
end
-- 播放卡牌受击效果
function EnemyView:DOHitEffect(time, func)
-- 时间修正
if not time or time < 0.3 then
time = 0.3
end
-- 受击放大1.2倍
self:DoScale(1.2, 0.1)
-- 卡面变红
self.RoleLiveGOGraphic:DOColor(Color.New(1,0,0,1), 0.1):OnComplete(function ()
self.RoleLiveGOGraphic:DOColor(Color.New(1,1,1,1), 0.1):SetDelay(time)
end)
-- 震动
self.RoleLiveGOTran:DOShakeAnchorPos(time, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
self.RoleLiveGO.transform.anchoredPosition = Vector2.New(self.outOffset[1], self.outOffset[2] )
-- 恢复大小
self:DoScale(1, 0.1)
-- 回调
if func then
func()
end
end)
end
function EnemyView:OnHealed(castRole)
local sortingOrder = nil
local go = BattleManager.LoadAsset(healEffect, sortingOrder)

View File

@ -456,10 +456,16 @@ local DotTypeTip = {
}
--
function PlayerView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
if skill and skill.continueTime > 0 and skill.attackCount > 1 then
local space = skill.continueTime / skill.attackCount
local count = skill.attackCount
local d = math.floor(dmg/count)
if skill then
-- 技能配置
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
local combat = BattleManager.GetSkillCombat(combatId)
--
local delay = combat.DamageDelay or 0
local continue = skill.continueTime or 0
local count = skill.attackCount or 1
local space = continue / count
local d = math.floor(dmg / count)
-- 如果平均伤害小于0 则
if d == 0 then
d = dmg
@ -468,22 +474,36 @@ function PlayerView:OnDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType
if BattleManager.IsBattleTestPanel() then
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s, 伤害段数:%s每段伤害%s", self.camp, self.role.position, dmg, count, d))
end
if count ~= 1 then
-- 后续伤害延迟打出
self:LoopFunc(space, count - 1, function()
self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
end)
-- 立刻打出第一次伤害
local fd = dmg - d *(count - 1)
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
else
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
end
-- 伤害文字延时,有些受击特效不是立刻播放文字
self:DelayFunc(delay/1000, function()
-- 伤害文字
if count ~= 1 then
-- 多段伤害
-- 后续伤害延迟打出
self:LoopFunc(space, count - 1, function()
self:OnceDamaged(atkRole, d, bCrit, finalDmg, damageType, dotType, skill)
end)
-- 立刻打出第一次伤害
local fd = dmg - d *(count - 1)
self:OnceDamaged(atkRole, fd, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect(continue)
else
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect()
end
end)
-- 播放特效
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
else
if BattleManager.IsBattleTestPanel() then
LogYellow(string.format("目标阵营:%s, 位置:%s, 总伤害:%s", self.camp, self.role.position, dmg))
end
-- 伤害文字
self:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotType, skill)
-- 被伤害卡牌表现
self:DOHitEffect()
end
end
--
@ -515,43 +535,49 @@ function PlayerView:OnceDamaged(atkRole, dmg, bCrit, finalDmg, damageType, dotTy
end
end
end
-- 播放受击动画
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
end
-- 播放卡牌受击效果
function PlayerView:DOHitEffect(time, func)
-- 时间修正
if not time or time < 0.3 then
time = 0.3
end
-- 受击放大1.2倍
self:DoScale(1.2, 0.1)
-- 卡面变红
DoTween.To(DG.Tweening.Core.DOGetter_float( function () return 1 end),
DG.Tweening.Core.DOSetter_float(function (progress)
local color = Color.New(1, progress, progress, 1)
Util.SetColor(self.GameObject, color)
Util.SetColor(self.RoleLiveGOGraphic, color)
end), 0, 0.3):SetEase(Ease.Linear):OnComplete(function()
end), 0, 0.1):SetEase(Ease.Linear):OnComplete(function()
DoTween.To(DG.Tweening.Core.DOGetter_float( function () return 0 end),
DG.Tweening.Core.DOSetter_float(function (progress)
local color = Color.New(1, progress, progress, 1)
Util.SetColor(self.GameObject, color)
Util.SetColor(self.RoleLiveGOGraphic, color)
end), 1, 0.1):SetEase(Ease.Linear)
end), 1, 0.1):SetEase(Ease.Linear):SetDelay(time)
end)
self.GameObject.transform.parent:DOShakeAnchorPos(0.3, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
-- 震动
self.GameObject.transform.parent:DOShakeAnchorPos(time, Vector2.New(200, 100), 100, 50, false, true):OnComplete(function ()
if self.GameObject then
self.GameObject.transform.parent.anchoredPosition = Vector2.New(self.role.position == 1 and -145 or 0, -221)
end
end)
-- 受击放大1.2倍
self:DoScale(1.2, 0.3, function()
-- 恢复大小
self:DoScale(1, 0.1)
-- 回调
if func then
func()
end
end)
-- 播放受击动画
self:PlaySpineAnim(self.RoleLiveGOGraphic, 0, "hit", false)
-- 播放受击特效
if skill then
local combatId = BattleManager.GetCombatIdBySkin(skill.id, atkRole.roleData.skinId)
local combat = BattleManager.GetSkillCombat(combatId)
self.SkillCaster:CheckSkillHitEffect("hit", combat, skill)
end
end
function PlayerView:OnHealed(castRole)
local sortingOrder = self.GameObject:GetComponent("Canvas").sortingOrder + 21
local go = BattleManager.LoadAsset(healEffect, sortingOrder)