zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Server/Hotfix/Game/SkillSystem/NewSkill/Component/SkillOptions/SkillOptionLogic_伤害.cs

90 lines
4.3 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
{
2023-09-07 00:06:37 +08:00
public class SkillOptionLogic_: SkillOptionLogicBase
2021-04-08 20:09:59 +08:00
{
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_>();
2023-09-07 00:06:37 +08:00
SelectTargetHelper.GetTarget(skillOption.selectTarget, skillSender, Action);
}
2021-04-08 20:09:59 +08:00
2023-09-07 00:06:37 +08:00
private async ETTask Action(Unit target, ISkillSender skillSender)
{
SkillOption_ skillOption = skillOptionBase.As<SkillOption_>();
Unit owner = skillSender.caster;
2021-04-08 20:09:59 +08:00
2023-09-07 00:06:37 +08:00
ModifierContainerComponent modifierContainer = owner.GetComponent<ModifierContainerComponent>();
(SkillOptionBase[] optionList, ModifierLogic __modifierLogic) =
modifierContainer.GetSkillOptionBaseArr(ModifierEventCondition.modifier);
if (optionList != null)
foreach (SkillOptionBase item in optionList)
2021-04-08 20:09:59 +08:00
{
2023-09-07 00:06:37 +08:00
SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
skillOptionLogicBase.HandleEvent(
new ModifierSkillSender(owner, target, __modifierLogic.skillConfigId, __modifierLogic));
2021-04-08 20:09:59 +08:00
}
2023-09-07 00:06:37 +08:00
AttackComponent attacker = owner.GetComponent<AttackComponent>();
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)
{
// ModifierId modifierId = _modifierSkillSender.modifierId;
// modifierLogic = modifierContainer.GetModifierLogic(modifierId);
modifierLogic = _modifierSkillSender.modifierLogic;
if (modifierLogic != null)
2021-04-08 20:09:59 +08:00
{
2023-09-07 00:06:37 +08:00
finalValue *= modifierLogic.overlay;
isCrit = skillOption.isCritEvent && data.isCrit;
if (isCrit)
modifierSkillSender = _modifierSkillSender;
2021-04-08 20:09:59 +08:00
}
2023-09-07 00:06:37 +08:00
}
2021-04-08 20:09:59 +08:00
2023-09-07 00:06:37 +08:00
if (skillOption.damageType == SkillDamageType.)
{
NumericComponent num = owner.GetComponent<NumericComponent>();
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);
}
data.ChangeValue(finalValue * attacker.multipleDamageX10000);
attacker.AttackTarget(target, data, skillSender);
if (isCrit)
{
Dictionary<ModifierEventCondition, SkillOptionBase[]> dic = modifierLogic.modifierConfig.modifierEventDic;
if (dic != null && dic.TryGetValue(ModifierEventCondition.modifier, out SkillOptionBase[] optionBaseList1))
foreach (SkillOptionBase item in optionBaseList1)
{
SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
skillOptionLogicBase.HandleEvent(modifierSkillSender);
}
2021-04-08 20:09:59 +08:00
2023-09-07 00:06:37 +08:00
// if (dic != null && dic.TryGetValue(ModifierEventCondition.当拥有modifier的单位被暴击时, out SkillOptionBase[] optionBaseList2))
// foreach (SkillOptionBase item in optionBaseList2)
// {
// SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item);
// skillOptionLogicBase.HandleEvent(modifierSkillSender);
// }
}
2021-04-08 20:09:59 +08:00
}
}
}