using UnityEngine;
using UnityEngine.SceneManagement;

public class MenuManager : MonoBehaviour {

    public string NextScene;

    public void Start() {
        PlayerPrefs.SetInt("CurrentLevel", 0);
        PlayerPrefs.SetInt("Score", 0);
        PlayerPrefs.SetString("Music", "On");

    }

    public void Update() {
        if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0)) {
            if (SceneManager.GetActiveScene().name != "Menu") {
                GoToNextScene();
            }
        }
	}

    public void GoToNextScene() {
        if (SceneManager.GetActiveScene().name == "GameOver" && Time.timeSinceLevelLoad < 1) {
            return;  // Prevent accidental space clicking in GameOver scene.
        }
        SceneManager.LoadScene(NextScene);
    }

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

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

}
