51 lines
900 B
C#
51 lines
900 B
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class Ability : MonoBehaviour
|
|
{
|
|
[Header("Cooldown")]
|
|
public float currentCooldown;
|
|
public float cooldown;
|
|
[Header("Stats")]
|
|
public int power;
|
|
|
|
[Header("Targetting")]
|
|
public Transform origin;
|
|
public Vector3 direction;
|
|
|
|
[Header("SFX")]
|
|
[SerializeField] protected AudioClip abilitySound;
|
|
[SerializeField] protected float volume = 1f;
|
|
|
|
[Header("Animation")]
|
|
[SerializeField] private Animator animator;
|
|
[SerializeField] private string attackTrigger;
|
|
|
|
public virtual bool TryAbility()
|
|
{
|
|
if (currentCooldown <= 0)
|
|
{
|
|
currentCooldown = cooldown;
|
|
AbilityEffects();
|
|
if (animator)
|
|
{
|
|
animator.SetTrigger(attackTrigger);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected virtual void AbilityEffects()
|
|
{
|
|
|
|
}
|
|
|
|
protected virtual void Update()
|
|
{
|
|
if (currentCooldown >= 0)
|
|
{
|
|
currentCooldown -= Time.deltaTime;
|
|
}
|
|
}
|
|
}
|