RiftMayhem/Assets/Scripts/Networking/ClassResourceSpender.cs
Pedro Gomes e1755999a3 Necromancer updates
- increase summon cost
- reduce amount of class resource drained on melee hits
- increased amount of class resource drained on spell with cooldown hits
- minions scaling with owner's stats
- bugfixing npc/minion decision making corner cases
2024-07-22 21:13:48 +01:00

43 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ClassResourceSpender : MonoBehaviour
{
RiftPlayer player;
Taggable playerTag;
ClassResource classResource;
ClassAbilityPriorityManager abilityPriorityManager;
AbilityCooldownTracker abilityCooldownTracker;
private void Awake()
{
player = GetComponentInParent<RiftPlayer>();
abilityPriorityManager = player.GetComponentInChildren<ClassAbilityPriorityManager>();
abilityCooldownTracker = player.GetComponentInChildren<AbilityCooldownTracker>();
playerTag = player.GetComponent<Taggable>();
classResource = player.GetComponent<ClassResource>();
classResource.onResourceChanged.AddListener(OnClassResourceValueChanged);
}
public void OnClassResourceValueChanged(float value)
{
BaseAbility autocastAbility = abilityPriorityManager.GetHighestPriorityAvailableAbility();
if (autocastAbility == null)
{
Debug.Log("No abilities available for current conditional state");
return;
}
autocastAbility.Execute(player.photonView, playerTag);
if (autocastAbility.cooldown > 0)
abilityCooldownTracker.StartAbilityCooldown(autocastAbility);
}
}