using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Ability : MonoBehaviour
{
    public string Name = "DefaultAbility";
    public float Cooldown = 5.0f;
    public bool Ready;

    public string Icon = "Sprites/UI/icon-confuse";

    // AE or Self

    protected float m_TimeLeft;
    public float TimeLeft { get { return m_TimeLeft; } }

    void Start()
    {
        Ready = true;
    }

    public void SetInfo(string _name, float _cooldown)
    {
        Name = _name;
        Cooldown = _cooldown;
    }

    public virtual void DoAction(Player _target)
    {

    }

    public virtual void Use(Player _owner)
    {
        if (Ready)
        {
            m_TimeLeft = Cooldown;
            Ready = false;

            DoAction(_owner);

            Debug.Log(Name + " used");
        }
    }

    public void Update()
    {
        if (!Ready)
        {
            m_TimeLeft -= Time.deltaTime;

            if (m_TimeLeft <= 0)
            {
                m_TimeLeft = 0;
                Ready = true;

                Debug.Log(Name + " ready");
            }
        }
    }
}
