CTT/Server/Hotfix/Game/SkillSystem/NewSkill/Component/SkillOptions/SkillOptionLogic_伤害.cs

90 lines
4.4 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using Cal;
using System;
2021-04-11 19:50:39 +08:00
using System.Collections.Generic;
2021-04-08 20:09:59 +08:00
namespace ET
{
public class SkillOptionLogic_ : SkillOptionLogicBase
{
public override SkillOptionType skillOptionType => SkillOptionType.;
public override SkillOptionBase skillOptionBase { get; set; }
public override void Clear()
{
}
public override void HandleEvent(ISkillSender skillSender)
{
SkillOption_ skillOption = skillOptionBase.As<SkillOption_>();
SelectTargetHelper.GetTarget(skillOption.selectTarget, skillSender, (target, skillSender) =>
{
2021-04-11 19:50:39 +08:00
Unit owner = skillSender.caster;
2021-04-08 20:09:59 +08:00
2021-04-11 19:50:39 +08:00
ModifierContainerComponent modifierContainer = owner.GetComponent<ModifierContainerComponent>();
(SkillOptionBase[] optionList, ModifierLogic __modifierLogic) = modifierContainer.GetSkillOptionBaseArr(ModifierEventCondition.modifier);
2021-04-08 20:09:59 +08:00
if (optionList != null)
2021-04-11 19:50:39 +08:00
foreach (SkillOptionBase item in optionList)
2021-04-08 20:09:59 +08:00
{
2021-04-11 19:50:39 +08:00
SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
2021-04-08 20:09:59 +08:00
skillOptionLogicBase.HandleEvent(new ModifierSkillSender
{
caster = owner,
target = target,
skillLogic = __modifierLogic.skillLogic,
modifierLogic = __modifierLogic
});
}
2021-04-11 19:50:39 +08:00
AttackComponent attacker = owner.GetComponent<AttackComponent>();
2021-04-08 20:09:59 +08:00
bool isCrit = false;
ModifierSkillSender modifierSkillSender = default;
ModifierLogic modifierLogic = null;
BattleHelper.Calculate(skillOption.damageType, skillSender, target, skillOption.damageCalculate_Self, skillOption.damageCalculate_Target, out BallisticData data);
float finalValue = data.value;
if (skillSender is ModifierSkillSender _modifierSkillSender)
{
modifierLogic = _modifierSkillSender.modifierLogic;
if (modifierLogic != null)
{
finalValue *= modifierLogic.overlay;
isCrit = skillOption.isCritEvent && data.isCrit;
if (isCrit)
modifierSkillSender = _modifierSkillSender;
}
}
if (skillOption.damageType == SkillDamageType.)
{
2021-04-11 19:50:39 +08:00
NumericComponent num = owner.GetComponent<NumericComponent>();
2021-04-08 20:09:59 +08:00
int pAtk = num.GetAsInt(NumericType.PhyAtk);
int sAtk = num.GetAsInt(NumericType.SpiAtk);
int atk = pAtk > sAtk ? pAtk : sAtk;
finalValue = Math.Clamp(finalValue, 1, atk * ConstDefine.RealDamageRate);
}
2021-04-18 15:54:51 +08:00
data.ChangeValue(finalValue * skillSender.skillLogic.GetMultipleDamage());
2021-04-08 20:09:59 +08:00
attacker.AttackTarget(target, data, skillSender);
if (isCrit)
{
2021-04-11 19:50:39 +08:00
Dictionary<ModifierEventCondition, SkillOptionBase[]> dic = modifierLogic.modifierConfig.modifierEventDic;
2021-04-08 20:09:59 +08:00
if (dic != null &&
2021-04-11 19:50:39 +08:00
dic.TryGetValue(ModifierEventCondition.modifier, out SkillOptionBase[] optionBaseList1))
foreach (SkillOptionBase item in optionBaseList1)
2021-04-08 20:09:59 +08:00
{
2021-04-11 19:50:39 +08:00
SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
2021-04-08 20:09:59 +08:00
skillOptionLogicBase.HandleEvent(modifierSkillSender);
}
if (dic != null &&
2021-04-11 19:50:39 +08:00
dic.TryGetValue(ModifierEventCondition.modifier, out SkillOptionBase[] optionBaseList2))
foreach (SkillOptionBase item in optionBaseList2)
2021-04-08 20:09:59 +08:00
{
2021-04-11 19:50:39 +08:00
SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
2021-04-08 20:09:59 +08:00
skillOptionLogicBase.HandleEvent(modifierSkillSender);
}
}
});
}
}
}