2021-04-08 20:09:59 +08:00
|
|
|
|
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_额外攻击目标>();
|
2021-04-11 19:50:39 +08:00
|
|
|
|
AttackComponent attacker = skillSender.caster.GetComponent<AttackComponent>();
|
|
|
|
|
TargetableUnitComponent targetUnits = skillSender.caster.GetComponent<TargetableUnitComponent>();
|
|
|
|
|
Unit currTarget = targetUnits.currTarget;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
if (targetUnits.targetList.Count <= 1)
|
|
|
|
|
return;
|
|
|
|
|
int index = 0;
|
2023-09-07 00:06:37 +08:00
|
|
|
|
int skillid = skillSender.skillConfigId;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
int count = SkillHotfixHelper.RandomNumber(skillid,skillOption. minCount,skillOption. maxCount, skillOption.isRndom);
|
2021-04-11 19:50:39 +08:00
|
|
|
|
foreach (Unit target in targetUnits.targetList)
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
if (target == currTarget)
|
|
|
|
|
continue;
|
2021-04-11 19:50:39 +08:00
|
|
|
|
if (!SkillHelper.GetParam(skillOption.valueParam, skillid, out float coefficent))
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
Log.Error($"the data is wrong where skillid is {skillid}");
|
|
|
|
|
coefficent = 1;
|
|
|
|
|
}
|
2021-04-11 19:50:39 +08:00
|
|
|
|
BallisticData attackData = attacker.GetAttackData();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
attackData.ChangeValue(MathHelper.RoundToInt(coefficent * attackData.value * MathF.Pow(ReduceCoefficent, ++index)));
|
|
|
|
|
attacker.AttackTarget(target, attackData, skillSender, false);
|
|
|
|
|
if (index >= count)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|