- working max health, properly setting health component values and showing scales on UI - working armor & magic resistance, properly mitigating incoming damage based on damage type
55 lines
2.1 KiB
C#
55 lines
2.1 KiB
C#
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;
|
|
|
|
DamageIncomeModifierEffectInstance targetDamageIncomeModifierEffect;
|
|
|
|
public override void ApplyEffect(Taggable user, List<Taggable> targets)
|
|
{
|
|
base.ApplyEffect(user, targets);
|
|
|
|
if (applyToTargetsHit)
|
|
{
|
|
foreach (Taggable target in targets)
|
|
{
|
|
targetDamageIncomeModifierEffect = target.GetComponent<DamageIncomeModifierEffectInstance>();
|
|
targetDamageIncomeModifierEffect.owner.RPC(nameof(targetDamageIncomeModifierEffect.RPC_ApplyDamageIncomeModifierEffect), targetDamageIncomeModifierEffect.owner.Owner, StatusEffectIndexer.Instance.StatusEffects.IndexOf(this), CalculateFinalAmount(user));
|
|
}
|
|
}
|
|
if(applyToSelf)
|
|
{
|
|
targetDamageIncomeModifierEffect = user.GetComponent<DamageIncomeModifierEffectInstance>();
|
|
targetDamageIncomeModifierEffect.ApplyEffect(this, CalculateFinalAmount(user));
|
|
}
|
|
}
|
|
|
|
|
|
private float CalculateFinalAmount(Taggable user)
|
|
{
|
|
float finalAmount = damageIncomeModifierPercentage;
|
|
CharacterStats stats = user.GetComponent<CharacterStats>();
|
|
|
|
foreach (var statInfluence in influencingStats)
|
|
{
|
|
if (stats.primaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat stat))
|
|
{
|
|
finalAmount += stat.Value * statInfluence.percentInfluence;
|
|
}
|
|
else if (stats.secondaryStatsDictionary.TryGetValue(statInfluence.statTag.name.ToLower(), out CharacterStat secondaryStat))
|
|
{
|
|
finalAmount += secondaryStat.Value * statInfluence.percentInfluence;
|
|
}
|
|
}
|
|
|
|
return finalAmount;
|
|
}
|
|
}
|