2025-02-21 15:26:23 +08:00
|
|
|
|
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);
|
2025-03-14 12:34:39 +08:00
|
|
|
|
owner.TakeNormalDamage(configData.AttackPowerLevel,damageInt, creator, false);
|
2025-02-21 15:26:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|