44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using Gameplay.Area;
|
|
using UnityEngine;
|
|
namespace Gameplay.Buff
|
|
{
|
|
public class BuffBulletDamage9 : BaseBuff
|
|
{
|
|
protected override void _OnTrigger()
|
|
{
|
|
base._OnTrigger();
|
|
|
|
// 【固定数值,攻击力百分比,目标周围友军增伤系数, search半径】
|
|
var fixValue = _TryGetFloatParam(0);
|
|
var rateAttack = _TryGetFloatParam(1);
|
|
var rateBuff = _TryGetFloatParam(2);
|
|
var searchRadius = _TryGetIntParam(3);
|
|
|
|
var centerCellIndex = owner.transData.cellIndex;
|
|
var aroundCells = AreaManager.instance.GetCellIndexsAround(centerCellIndex, searchRadius);
|
|
var aroundFriendCount = 0;
|
|
for (int i = 0; i < aroundCells.Count; i++)
|
|
{
|
|
var aroundCellIndex = aroundCells[i];
|
|
var units = AreaManager.instance.GetUnitsByCellIndex(aroundCellIndex);
|
|
for (int j = 0; j < units.Count; j++)
|
|
{
|
|
var unit = units[j];
|
|
if (unit == owner)
|
|
{
|
|
continue;
|
|
}
|
|
if (unit.commonData.troopId == creator.commonData.troopId)
|
|
{
|
|
aroundFriendCount++;
|
|
}
|
|
}
|
|
}
|
|
|
|
var damage = Mathf.FloorToInt((fixValue + rateAttack * owner.fightData.attack) * (1 + rateBuff * aroundFriendCount));
|
|
|
|
owner.TakeNormalDamage(damage, creator, false);
|
|
}
|
|
}
|
|
}
|