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

public class PauseMenu : MonoBehaviour {

	public static bool GameIsPaused = false;

	public GameObject pauseMenuUI;


	// Update is called once per frame
	void Update () {
		if (Input.GetKeyDown (KeyCode.Escape)) {

			if (GameIsPaused) {
				Resume ();
			} else 
			{
				Pause();
			}

		}
	}

	// Disables the pause menu canvas, puts game timescale back to normal, sets paused bool to false
	public void Resume()
	{
		pauseMenuUI.SetActive (false);
		Time.timeScale = 1f;
		GameIsPaused = false;
	}

	// Enables the pause menu canvas, puts game timescale to 0, sets paused bool to true
	void Pause()
	{
		pauseMenuUI.SetActive (true);
		Time.timeScale = 0f;
		GameIsPaused = true;
	}
}
