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

public class GameOverMenu : MonoBehaviour {

	public string currentLevel;
	public string nextLevel;

	public string mainMenu;

	public Text gameOverScore;
	public Text gameWonScore;
	public GameObject gameOverCanvas;
	public GameObject gameWonCanvas;

	private int score;

	public LevelManager levelManager;

	void Start () {
		levelManager = FindObjectOfType<LevelManager> ();
	}

	void Update(){
		score = ScoreManager.getScore ();
		if (levelManager.showGameOverMenu()) {
			gameOverScore.text = "Score: " + score;
			gameOverCanvas.SetActive (true);
			ScoreManager.setHightScore (currentLevel);
		}
		if (levelManager.showGameWonMenu()) {
			gameWonScore.text = "Score: " + score;
			gameWonCanvas.SetActive (true);
			ScoreManager.setHightScore (currentLevel);
		}
	}

	public string getCurrectLevel(){
		return currentLevel;
	}

	public void goNextLevel(){
		SceneManager.LoadScene (nextLevel);
	}

	public void restart(){
		SceneManager.LoadScene (currentLevel);
	}

	public void quit(){
		SceneManager.LoadScene (mainMenu);
	}
}
