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

public class GameController : MonoBehaviour {

	public static GameController instance;
	public GameObject GameOverText;
	public bool GameOver = false;
	public Text ScoreText;

	private int score = 0;
	// Use this for initialization
	void Awake () {
		if (instance == null) {
			instance = this;
		} else if (instance != null) {
			Destroy (gameObject);
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (GameOver == true && Input.GetKeyUp ("space")) {
			SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
		}		
	}

	public void GameScore(){
		if (GameOver) {
			return;
		} else {
			score++;
			ScoreText.text = "Score: " + score.ToString ();
		}
	}

	public void Died(){
		GameOverText.SetActive (true);
		GameOver = true;
	}
}
