Pedro Gomes a966809f20 Update with class & attack
- melee attack first iteration (WIP)
- priest playable class
- priest "holy ball" ability
2024-05-21 20:37:07 +01:00

59 lines
2.0 KiB
C#

using Kryz.CharacterStats;
using Kryz.CharacterStats.Examples;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "InstantEffect", menuName = "RiftMayhem/AbilitySystem/Effects/Instant Effect", order = 1)]
public class InstantValueEffect : BaseEffect
{
public float baseValue;
public float percentStatInfluence;
Health targetHealth;
private float finalValue;
private CharacterStats stats;
public override void ApplyEffect(Taggable user, List<Taggable> targets)
{
foreach (Taggable target in targets)
{
Debug.Log($"Applied instant effect of {GetCorrectValueSign(user, target)} to target {target.name}");
targetHealth = target.GetComponent<Health>();
targetHealth.photonView.RPC(nameof(targetHealth.RPC_ChangeValueHealth), targetHealth.photonView.Owner, GetCorrectValueSign(user, target));
//targetHealth.ChangeValue(target.targetTag == TargettingTag.Enemy ? -value : value);
}
}
private float GetCorrectValueSign(Taggable user, Taggable target)
{
stats = user.GetComponent<CharacterStats>();
GetFinalValue(GetCorrectStat(stats));
return user.targetTag.AlliedTags.Contains(target.targetTag) ? finalValue : -finalValue;
}
private CharacterStat GetCorrectStat(CharacterStats stats) //TODO: make it use multiple stats correctly
{
for (int i = 0; i < influencingStats.Count; i++)
{
if (stats.statsDictionary.ContainsKey(influencingStats[i].name.ToLower()))
{
Debug.Log($"Influencing effect using: {influencingStats[i].name.ToLower()}");
return stats.statsDictionary[influencingStats[i].name.ToLower()];
}
}
return null;
}
private void GetFinalValue(CharacterStat stat)
{
if (stat == null)
finalValue = baseValue;
else
finalValue = baseValue + stat.Value * percentStatInfluence;
}
}