using Cal; using System; using System.Collections.Generic; 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(); SelectTargetHelper.GetTarget(skillOption.selectTarget, skillSender, Action); } private async ETTask Action(Unit target, ISkillSender skillSender) { SkillOption_伤害 skillOption = skillOptionBase.As(); Unit owner = skillSender.caster; ModifierContainerComponent modifierContainer = owner.GetComponent(); (SkillOptionBase[] optionList, ModifierLogic __modifierLogic) = modifierContainer.GetSkillOptionBaseArr(ModifierEventCondition.当拥有modifier的单位攻击到某个目标时); if (optionList != null) foreach (SkillOptionBase item in optionList) { SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item); skillOptionLogicBase.HandleEvent( new ModifierSkillSender(owner, target, __modifierLogic.skillConfigId, __modifierLogic)); } AttackComponent attacker = owner.GetComponent(); 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) { finalValue *= modifierLogic.overlay; isCrit = skillOption.isCritEvent && data.isCrit; if (isCrit) modifierSkillSender = _modifierSkillSender; } } if (skillOption.isDamageLimited) { NumericComponent num = skillSender.caster.GetComponent(); NumericComponent numTarget = target.GetComponent(); 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.真实伤害) { //缺省预留 NumericComponent num = owner.GetComponent(); int pAtk = num.GetAsInt(NumericType.PhyAtk); int sAtk = num.GetAsInt(NumericType.SpiAtk); int atk = Math.Max(pAtk,sAtk); finalValue = Math.Clamp(finalValue, 1, atk * ConstDefine.RealDamageRate); } data.ChangeValue(finalValue * attacker.multipleDamageX10000); attacker.AttackTarget(target, data, skillSender); if (isCrit) { Dictionary 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); } // if (dic != null && dic.TryGetValue(ModifierEventCondition.当拥有modifier的单位被暴击时, out SkillOptionBase[] optionBaseList2)) // foreach (SkillOptionBase item in optionBaseList2) // { // SkillOptionLogicBase skillOptionLogicBase = SkillOptionFactory.AcquireSkillOptionLogic(item); // skillOptionLogicBase.HandleEvent(modifierSkillSender); // } } } } }