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

public abstract class Power : MonoBehaviour
{
    [SerializeField]
    float p_myCoolDown;
    [SerializeField]
    int p_myClickNumber;
    float p_myTimer;
    bool p_myIsActive;
    bool p_myIsLoaded;

    public int getClickNumber()
    {
        return p_myClickNumber;
    }

    public void setActive()
    {
        p_myIsActive = true;
    }

    public float getRatio()
    {
        return p_myTimer / p_myCoolDown;
    }

    void PowerActivated()
    {
        if (p_myIsActive)
        {
            if (p_myIsLoaded)
            {
                StartCoroutine(CoolDown());
            }
        }
    }

    IEnumerator CoolDown()
    {
        p_myIsLoaded = false;
        p_myTimer = 0;
        do
        {
            p_myTimer += Time.deltaTime;
            yield return new WaitForEndOfFrame();
        } while (p_myTimer < p_myCoolDown);
        p_myIsLoaded = true;
    }

    public virtual void PowerEffect(Vector3 pos)
    {
        ScreenShakeManager.instance.ScreenShake();
        PowerActivated();
    }
}