using UnityEngine;
using UnityEngine.UI;

public class PauseScript : MonoBehaviour
{
    private float _currentSpeed = regularSpeed;

    public const float regularSpeed = 1;
    public const float pauseSpeed = 0;
    public const float fastSpeed = 1.5f;

    [SerializeField]
    private Button _pauseButton;
    [SerializeField]
    private Button _speedButton;

    public void Pause()
    {
        _pauseButton.image.color = Color.black;
        Time.timeScale = pauseSpeed;
    }
    public void Resume()
    {
        _pauseButton.image.color = Color.white;
        Time.timeScale = _currentSpeed;
    }
    public void ToggleSpeed()
    {
        if (Time.timeScale == 1f)
        {
            _speedButton.image.color = Color.yellow;
            Time.timeScale = _currentSpeed = fastSpeed;
        }
        else
        {
            _speedButton.image.color = Color.white;
            Time.timeScale = _currentSpeed = regularSpeed;
        }
    }

    /// <summary>
    /// Remet la vitesse de jeux a son etat normal lorsque le dernier ennemi est mort, si necessaire
    /// </summary>
    public void ResetGameSpeed()
    {
        _speedButton.image.color = Color.white;
        Time.timeScale = regularSpeed;
    }
}