using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; public class SpiritPowerAutocast : MonoBehaviour { protected RiftPlayer player; protected Taggable playerTag; protected SpiritPower spiritPower; protected ClassAbilityPriorityManager abilityPriorityManager; protected AbilityCooldownTracker abilityCooldownTracker; protected virtual void Awake() { player = GetComponentInParent(); abilityPriorityManager = player.GetComponentInChildren(); abilityCooldownTracker = player.GetComponentInChildren(); playerTag = player.GetComponent(); spiritPower = player.GetComponent(); //spiritPower.onResourceChanged.AddListener(OnClassResourceValueChanged); } private void Start() { //KeepCasting(); } public void KeepCasting() { BaseAbility autocastAbility = abilityPriorityManager.GetHighestPriorityAvailableAbility(); if (autocastAbility == null) { Debug.Log("#A No abilities available for current conditional state: " + autocastAbility); KeepCasting(); return; } Debug.Log("#A Executing Spirit power Autocast: " + autocastAbility.name); if (autocastAbility.cooldown > 0) abilityCooldownTracker.StartAbilityCooldown(autocastAbility); autocastAbility.Execute(playerTag); } public virtual void OnClassResourceValueChanged(float value) { BaseAbility autocastAbility = abilityPriorityManager.GetHighestPriorityAvailableAbility(); if (autocastAbility == null) { Debug.Log("#A No abilities available for current conditional state: " + autocastAbility); return; } Debug.Log("#A Executing Spirit power Autocast: " + autocastAbility.name); if (autocastAbility.cooldown > 0) abilityCooldownTracker.StartAbilityCooldown(autocastAbility); autocastAbility.Execute(playerTag); } }