73 lines
2.1 KiB
C#
73 lines
2.1 KiB
C#
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<RiftPlayer>();
|
|
abilityPriorityManager = player.GetComponentInChildren<ClassAbilityPriorityManager>();
|
|
abilityCooldownTracker = player.GetComponentInChildren<AbilityCooldownTracker>();
|
|
playerTag = player.GetComponent<Taggable>();
|
|
spiritPower = player.GetComponent<SpiritPower>();
|
|
|
|
//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);
|
|
|
|
}
|
|
}
|