Pedro Gomes e1081a2bf4 Necromancer and Minions update
- Necromancer class playable
- Savage minion ability & npc
- Mage minion ability & npc
- rogue minion ability & npc
- warrior minion ability & npc
- golem minion ability & npc
- minion abilities
- Class resource (used to automatically summon minions based on the amount of souls drained, in case of necromancer)
- class resource spender (auto cast from priority list)
- class resource regen instant effect option
2024-07-22 16:46:13 +01:00

84 lines
2.6 KiB
C#

using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//[CreateAssetMenu(fileName = "BaseAbility", menuName = "RiftMayhem/AbilitySystem/Abilities/Base Ability", order = 1)]
public class BaseAbility : ScriptableObject
{
public Sprite Icon;
public List<TargetTag> targettingTags = new List<TargetTag>();
public List<GameTag> tags = new List<GameTag>();
public List<BaseEffect> abilityEffects = new List<BaseEffect>();
[Space]
public float castTime;
public float manaCost;
public float healthCost = 0;
public float classResourceCost = 0;
public float cooldown;
public bool castableWhileMoving;
public AbilityAnimationType animationType;
public virtual void Execute(PhotonView user, Taggable userTag)
{
user.GetComponent<Mana>().ChangeValue(-manaCost);
user.GetComponent<Health>().ChangeValue(-healthCost);
user.GetComponent<ClassResource>()?.ChangeValue(-classResourceCost);
//for (int i = 0; i < abilityEffects.Count; i++)
//{
// Debug.Log($"Ability {this.name} applied {abilityEffects[i].name} effect at xtarget");
//}
}
public virtual void Execute(PhotonView user, Taggable userTag, Vector3 point)
{
user.GetComponent<Mana>().ChangeValue(-manaCost);
user.GetComponent<Health>().ChangeValue(-healthCost);
user.GetComponent<ClassResource>()?.ChangeValue(-classResourceCost);
}
public virtual void Execute(PhotonView user, Taggable userTag, Transform target)
{
user.GetComponent<Mana>().ChangeValue(-manaCost);
user.GetComponent<Health>().ChangeValue(-healthCost);
user.GetComponent<ClassResource>()?.ChangeValue(-classResourceCost);
}
private void OnValidate()
{
InitializeUniqueTags();
}
private void OnEnable()
{
InitializeUniqueTags();
}
public void InitializeUniqueTags()
{
tags.Clear();
// Iterate through each effect and add unique GameTags to uniqueTags list
foreach (var effect in abilityEffects)
{
if (effect != null)
{
foreach (var tag in effect.tags)
{
if (!tags.Contains(tag))
{
tags.Add(tag);
}
}
foreach (var influencingStat in effect.influencingStats)
{
if(!tags.Contains(influencingStat.statTag))
{
tags.Add(influencingStat.statTag);
}
}
}
}
}
}