using UnityEngine.SceneManagement;
using UnityEngine;

public class SceneManagement : MonoBehaviour {


    public GameObject pauseUI;

    private void Awake()
    {
        Time.timeScale = 1;
    }

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if(SceneManager.GetActiveScene().buildIndex == 1)
            {
                if(Time.timeScale == 1)
                {
                    //Pause game and show ui
                    Time.timeScale = 0;
                    pauseUI.SetActive(true);
                }
                else
                {
                    //Unpause game and hide ui
                    Time.timeScale = 1;
                    pauseUI.SetActive(false);
                }
            }
        }
    }

    public void ResumeGame()
    {
        if (SceneManager.GetActiveScene().buildIndex == 1)
        {
            if (Time.timeScale == 0)
            {
                //Unpause game and hide ui
                Time.timeScale = 1;
                pauseUI.SetActive(false);
            }
        }
    }

    public void LoadLevel(int level)
    {
        SceneManager.LoadScene(level);
    }

    public void RestartLevel()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

    public void QuitGame()
    {
        Application.Quit();
    }
}
