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

public class PauseMenu : MonoBehaviour
{
    public static bool gameIsPause = false;

    public GameObject pauseMenuUI;
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (gameIsPause)
            {
                Resume();
                Debug.Log("Riprendi");
            }
            else
            {
                Pause();
                Debug.Log("Menu in pausa");
            }
        }
    }

    public void Resume()
    {
        pauseMenuUI.SetActive(false);
        Time.timeScale = 1f;
        gameIsPause = false;
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pauseMenuUI.SetActive(false);
            Time.timeScale = 1f;
            gameIsPause = false;
        }
    }

    void Pause()
    {
        pauseMenuUI.SetActive(true);
        Time.timeScale = 0f;
        gameIsPause = true;
    }

    public void loadingMenu()
    {
        Time.timeScale = 1f;
        pauseMenuUI.SetActive(false);
        SceneManager.LoadScene("Menu");
        Debug.Log("Menu iniziale");
    }

    public void quit()
    {
        Debug.Log("Esci dal gioco");
        Application.Quit();
    }
}
