NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Buff/Impl/BuffBulletDamage1.cs

73 lines
2.2 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using Gameplay.Common;
using Gameplay.Unit.Data;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Buff
{
using UnityEngine;
2024-03-22 14:25:27 +08:00
public class BuffBulletDamage1 : BaseBuff
2023-08-22 19:08:45 +08:00
{
protected override void _OnTrigger()
{
base._OnTrigger();
var sender = creator;
2023-08-22 19:08:45 +08:00
var senderAttack = sender.fightData.attack;
var floatValueA = _TryGetFloatParam(0);
var floatValueB = _TryGetFloatParam(1);
2023-08-22 19:08:45 +08:00
var finalDamage = floatValueA + senderAttack * floatValueB;
var typeScale = _GetScaleForUnitType();
finalDamage *= typeScale;
2023-08-22 19:08:45 +08:00
// 造成伤害
owner.TakeNormalDamage(Mathf.CeilToInt(finalDamage), sender, false);
}
private float _GetScaleForUnitType()
{
var scaleValue1 = _TryGetFloatParam(2, 1);
var scaleValue2 = _TryGetFloatParam(3, 1);
var scaleValue3 = _TryGetFloatParam(4, 1);
2023-08-22 19:08:45 +08:00
// 如果目标是人形还要进行增伤
if (owner.gameunitType == EGameUnitType.Character)
2023-08-22 19:08:45 +08:00
{
return scaleValue1;
2023-08-22 19:08:45 +08:00
}
// 如果目标是载具还要进行增伤
if (owner.gameunitType == EGameUnitType.Vehicle)
2023-08-22 19:08:45 +08:00
{
return scaleValue2;
2023-08-22 19:08:45 +08:00
}
// 如果目标是建筑还要进行增伤
if (owner.gameunitType == EGameUnitType.Building)
2023-08-22 19:08:45 +08:00
{
return scaleValue3;
2023-08-22 19:08:45 +08:00
}
if (owner.gameunitType == EGameUnitType.Summon)
{
var unitSummon = owner as Summon.BaseSummon;
if (unitSummon == null)
{
return 1f;
}
if (unitSummon.subUnitType == EGameUnitType.Character)
{
return scaleValue1;
}
if (unitSummon.subUnitType == EGameUnitType.Vehicle)
{
return scaleValue2;
}
if (unitSummon.subUnitType == EGameUnitType.Building)
{
return scaleValue3;
}
}
return 1f;
2023-08-22 19:08:45 +08:00
}
2023-08-22 19:08:45 +08:00
}
}