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


public class ResultsScreen : MonoBehaviour {

	public Text results;
	public Text pac;
	public Text dracula;
	public Text ghost;
	public Text werewolf;
	public Text zombie;
	// Use this for initialization
	void Start () 
	{
		//getData
		if (AllScores.all_scores.results != null && AllScores.all_scores.results != "")
		{
			results.text = AllScores.all_scores.results;
		}


        if (AllScores.all_scores.time != "")
        {
            pac.text = "" + AllScores.all_scores.time + "s";
        } 
        else if (AllScores.all_scores.scores.ContainsKey("pac"))
		{
			pac.text = "" + AllScores.all_scores.scores ["pac"] + " Pellet" + (AllScores.all_scores.scores ["pac"] != 1 ? "s" : " ");
		}

		if (AllScores.all_scores.scores.ContainsKey("dracula"))
		{
			dracula.text = "" + AllScores.all_scores.scores ["dracula"] + " Kill" + (AllScores.all_scores.scores ["dracula"] != 1 ? "s" : " ");
		}

		if (AllScores.all_scores.scores.ContainsKey("ghost"))
		{
			ghost.text = "" + AllScores.all_scores.scores["ghost"] + " Kill" + (AllScores.all_scores.scores ["ghost"] != 1 ? "s" : " ");
		}

		if (AllScores.all_scores.scores.ContainsKey("werewolf"))
		{
			werewolf.text = "" + AllScores.all_scores.scores ["werewolf"] + " Kill" + (AllScores.all_scores.scores ["werewolf"] != 1 ? "s" : " ");
		}

		if (AllScores.all_scores.scores.ContainsKey("zombie"))
		{
			zombie.text = "" + AllScores.all_scores.scores ["zombie"] + " Kill" + (AllScores.all_scores.scores ["zombie"] != 1 ? "s" : " ");
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (Input.GetButtonDown("Submit")) 
		{

			if (AllScores.all_scores != null)
				Destroy(AllScores.all_scores.gameObject);
			
			SceneManager.LoadScene("MainMenu");
		}
	}
}
