using Kryz.CharacterStats; using Kryz.CharacterStats.Examples; using System.Collections; using System.Collections.Generic; using UnityEngine; [CreateAssetMenu(fileName = "DamageIncomeModifierEffect", menuName = "RiftMayhem/AbilitySystem/Effects/DamageIncomeModifier Effect", order = 1)] public class DamageIncomeModifierEffect : StatusEffect { public float damageIncomeModifierPercentage; public bool avoidAllies = false; DamageIncomeModifierEffectInstance targetDamageIncomeModifierEffect; public override void ApplyEffect(Taggable user, List targets) { base.ApplyEffect(user, targets); if (applyToTargetsHit) { foreach (Taggable target in targets) { if(avoidAllies) { if (user.AlliedTagsContains(target.targetTag)) continue; } targetDamageIncomeModifierEffect = target.GetComponent(); targetDamageIncomeModifierEffect.owner.RPC(nameof(targetDamageIncomeModifierEffect.RPC_ApplyDamageIncomeModifierEffect), targetDamageIncomeModifierEffect.owner.Owner, StatusEffectIndexer.Instance.StatusEffects.IndexOf(this), CalculateFinalAmount(user)); } } if(applyToSelf) { targetDamageIncomeModifierEffect = user.GetComponent(); targetDamageIncomeModifierEffect.ApplyEffect(this, CalculateFinalAmount(user)); } } private float CalculateFinalAmount(Taggable user) { float finalAmount = damageIncomeModifierPercentage; CharacterStats stats = user.GetComponent(); foreach (var statInfluence in influencingStats) { if (stats.primaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat stat)) { Debug.Log("#DIMod: " + this.name + " = " + damageIncomeModifierPercentage + " += " + stat.Value + " * " + statInfluence.percentInfluence); finalAmount += stat.Value * statInfluence.percentInfluence; } else if (stats.secondaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat secondaryStat)) { Debug.Log("#DIMod: " + this.name + " = " + damageIncomeModifierPercentage + " += " + stat.Value + " * " + statInfluence.percentInfluence); finalAmount += secondaryStat.Value * statInfluence.percentInfluence; } } Debug.Log("#DIMod: " + this.name + " finalAmount = " + finalAmount); return finalAmount; } }