41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
|
using Cal;
|
|||
|
using System;
|
|||
|
namespace ET
|
|||
|
{
|
|||
|
public class SkillOptionLogic_额外攻击目标 : SkillOptionLogicBase
|
|||
|
{
|
|||
|
public override SkillOptionType skillOptionType => SkillOptionType.额外攻击目标;
|
|||
|
public override SkillOptionBase skillOptionBase { get; set; }
|
|||
|
|
|||
|
SkillOption_额外攻击目标 skillOption;
|
|||
|
//!递减系数
|
|||
|
const float ReduceCoefficent = 0.75f;
|
|||
|
public override void HandleEvent(ISkillSender skillSender)
|
|||
|
{
|
|||
|
skillOption = skillOptionBase.As<SkillOption_额外攻击目标>();
|
|||
|
var attacker = skillSender.caster.GetComponent<AttackComponent>();
|
|||
|
var targetUnits = skillSender.caster.GetComponent<TargetableUnitComponent>();
|
|||
|
var currTarget = targetUnits.currTarget;
|
|||
|
if (targetUnits.targetList.Count <= 1)
|
|||
|
return;
|
|||
|
int index = 0;
|
|||
|
int skillid = skillSender.skillLogic.skillConfigId;
|
|||
|
int count = SkillHotfixHelper.RandomNumber(skillid,skillOption. minCount,skillOption. maxCount, skillOption.isRndom);
|
|||
|
foreach (var target in targetUnits.targetList)
|
|||
|
{
|
|||
|
if (target == currTarget)
|
|||
|
continue;
|
|||
|
if (!SkillHelper.GetParam(skillOption.valueParam, skillid, out var coefficent))
|
|||
|
{
|
|||
|
Log.Error($"the data is wrong where skillid is {skillid}");
|
|||
|
coefficent = 1;
|
|||
|
}
|
|||
|
var attackData = attacker.GetAttackData();
|
|||
|
attackData.ChangeValue(MathHelper.RoundToInt(coefficent * attackData.value * MathF.Pow(ReduceCoefficent, ++index)));
|
|||
|
attacker.AttackTarget(target, attackData, skillSender, false);
|
|||
|
if (index >= count)
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|