using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class PauseUI : MonoBehaviour
{
    private const string MAIN_MENU = "MainMenu";
    private const string BARREN_LAND = "BarrenLand";
    [SerializeField] private GameObject pausePanel;
    [SerializeField] private GameObject gameOverPanel;
    
    void Awake() {
        pausePanel.SetActive(false);
        gameOverPanel.SetActive(false);
        PlayerManager.I.playerDeath += GameOver;
    }

    void OnDestroy() {
        if(PlayerManager.HasInstance) {
            PlayerManager.I.playerDeath -= GameOver;
        }
    }

    public void Pause() {
        pausePanel.SetActive(true);
        Time.timeScale = 0f;
    }

    public void Resume() {
        pausePanel.SetActive(false);
        Time.timeScale = 1f;
    }

    public void ToHome() {
        Time.timeScale = 1f;
        SceneManager.LoadScene(MAIN_MENU);
    }

    public void GameOver() {
        gameOverPanel.SetActive(true);
        Time.timeScale = 0f;
    }

    public void Restart() {
        Time.timeScale = 1f;
        SceneManager.LoadScene(BARREN_LAND);
    }
}
