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-10 23:57:57 +08:00
|
|
|
|
if (skillOption.isDamageLimited)
|
2023-09-07 00:06:37 +08:00
|
|
|
|
{
|
2023-09-10 23:57:57 +08:00
|
|
|
|
NumericComponent num = skillSender.caster.GetComponent<NumericComponent>();
|
|
|
|
|
NumericComponent numTarget = target.GetComponent<NumericComponent>();
|
|
|
|
|
int skillConfigId = skillSender.skillConfigId;
|
|
|
|
|
ValueCalculate skillOptionDamageCalculateLimit = skillOption.damageCalculate_Limit;
|
|
|
|
|
if (skillOptionDamageCalculateLimit != null)
|
|
|
|
|
{
|
|
|
|
|
if (SkillHelper.GetParam(skillOptionDamageCalculateLimit.param, skillConfigId, out float damageLimitMuliter))
|
|
|
|
|
{
|
|
|
|
|
BattleHelper.GetNumType(skillOptionDamageCalculateLimit, NumTargetType.Self, num, numTarget, out NumericComponent num1, out NumericType numericType1);
|
|
|
|
|
|
|
|
|
|
float damageLimitBasisValue = num1.Get(numericType1);
|
|
|
|
|
var damageLimited = damageLimitMuliter/100f* damageLimitBasisValue;
|
|
|
|
|
finalValue = Math.Clamp(finalValue, 1, damageLimited);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (skillOption.damageType == SkillDamageType.真实伤害)
|
|
|
|
|
{
|
|
|
|
|
//缺省预留
|
2023-09-07 00:06:37 +08:00
|
|
|
|
NumericComponent num = owner.GetComponent<NumericComponent>();
|
|
|
|
|
int pAtk = num.GetAsInt(NumericType.PhyAtk);
|
|
|
|
|
int sAtk = num.GetAsInt(NumericType.SpiAtk);
|
2023-09-10 23:57:57 +08:00
|
|
|
|
int atk = Math.Max(pAtk,sAtk);
|
2023-09-07 00:06:37 +08:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|