- 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
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using UnityEngine;
|
|
using UnityEngine.AI;
|
|
using System.Collections.Generic;
|
|
using Kryz.CharacterStats.Examples;
|
|
using Kryz.CharacterStats;
|
|
|
|
[CreateAssetMenu(fileName = "MovementSpeedModifierEffect", menuName = "RiftMayhem/AbilitySystem/Effects/Movement Speed Modifier Effect", order = 1)]
|
|
public class MovementSpeedModifierEffect : StatusEffect
|
|
{
|
|
public float speedModifierPercentage;
|
|
|
|
MovementSpeedModifierEffectInstance targetMovementSpeedModifierEffect;
|
|
|
|
public override void ApplyEffect(Taggable user, List<Taggable> targets)
|
|
{
|
|
base.ApplyEffect(user, targets);
|
|
|
|
if (applyToTargetsHit)
|
|
{
|
|
foreach (Taggable target in targets)
|
|
{
|
|
if (IsAlliedTarget(user, target))
|
|
{
|
|
targetMovementSpeedModifierEffect = target.GetComponent<MovementSpeedModifierEffectInstance>();
|
|
targetMovementSpeedModifierEffect.owner.RPC(nameof(targetMovementSpeedModifierEffect.RPC_ApplyMovementSpeedModifierEffect), targetMovementSpeedModifierEffect.owner.Owner, StatusEffectIndexer.Instance.StatusEffects.IndexOf(this), CalculateFinalAmount(user));
|
|
}
|
|
}
|
|
}
|
|
if (applyToSelf)
|
|
{
|
|
targetMovementSpeedModifierEffect = user.GetComponent<MovementSpeedModifierEffectInstance>();
|
|
targetMovementSpeedModifierEffect.ApplyEffect(this, CalculateFinalAmount(user));
|
|
}
|
|
}
|
|
|
|
private bool IsAlliedTarget(Taggable user, Taggable target)
|
|
{
|
|
return user.AlliedTagsContains(target.targetTag);
|
|
}
|
|
|
|
private float CalculateFinalAmount(Taggable user)
|
|
{
|
|
float finalAmount = speedModifierPercentage;
|
|
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;
|
|
}
|
|
} |