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

71 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Gameplay.Area;
using Gameplay.Unit.Data;
using UnityEngine;
namespace Gameplay.Buff
{
public class BuffBulletDamage14 : BaseBuff
{
protected override void _OnTrigger()
{
base._OnTrigger();
// 吸收周围距离1人员单位最大5%(生命+护盾对目标造成A+吸收值5%的伤害
// [最大百分比A, 固伤B, 吸收值系数C]
// 1. 吸收效果走真伤判断
// 2. 不会吸死,至少保留1滴血
// 3. 吸收值取具体吸收量
// 4. 只能吸友军的角色类型
var paramA = _TryGetFloatParam(0);
var paramB = _TryGetFloatParam(1);
var paramC = _TryGetFloatParam(2);
var creatorCellIndex = creator.transData.cellIndex;
var aroundCellIndexList = AreaManager.instance.GetCellIndexsAround(creatorCellIndex, 1, false);
var totalAbsorb = 0;
for (int i = 0; i < aroundCellIndexList.Count; i++)
{
var checkCellIndex = aroundCellIndexList[i];
var units = AreaManager.instance.GetUnitsByCellIndex(checkCellIndex);
for (int j = 0; j < units.Count; j++)
{
var unit = units[j];
if (unit.commonData.troopId != creator.commonData.troopId)
{
continue;
}
if (unit.gameunitType != EGameUnitType.Character)
{
continue;
}
if (!unit.statusData.isOnFloor)
{
continue;
}
if (unit.statusData.isDead)
{
continue;
}
var totalHp = unit.aliveData.maxHp + unit.aliveData.maxShield;
var absorb = totalHp * paramA;
var nowHp = unit.aliveData.currentHp + unit.aliveData.currentShield;
if (nowHp - absorb <= 1)
{
absorb = nowHp - 1;
}
var absorbInt = Mathf.FloorToInt(absorb);
totalAbsorb += absorbInt;
unit.TakePureDamage(absorbInt, creator);
}
}
var damage = paramB + totalAbsorb * paramC;
var damageInt = Mathf.FloorToInt(damage);
owner.TakeNormalDamage(configData.AttackPowerLevel,damageInt, creator, false);
}
}
}