using UnityEngine;
public abstract class Ability : ScriptableObject
{
[Header("Ability Settings")]
public string abilityName;
public string abilityKey;
public KeyCode keybind; // Key to activate the ability
public float cooldownTime; // Cooldown duration in seconds
private float lastActivationTime;
///
/// Checks if the ability can be activated (e.g., not on cooldown).
///
public bool CanActivate()
{
return Time.time >= lastActivationTime + cooldownTime;
}
///
/// Invokes the ability.
///
/// The GameObject or player triggering this ability.
public void TryActivate(GameObject owner)
{
if (CanActivate())
{
Activate(owner);
lastActivationTime = Time.time;
}
else
{
Debug.Log($"{abilityName} is on cooldown.");
}
}
protected abstract void Activate(GameObject owner); // Logic for the specific ability
}