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

public class ScoreUI : MonoBehaviour {
    public PlayerControls controls;
    public Text scoreText;
	// Use this for initialization

    public Transform winPanel;
    public Text winScoreText;


    bool gameWon;
	// Update is called once per frame
	void Update () {
        scoreText.text = controls.GetScoreString();

	    if (controls.GameWon() && !gameWon)
	    {
	        var winString = string.Format("Colony size: {0}\n Time: {1:F}", controls.GetCellCount(), Time.time);
	        winScoreText.text = winString;
	        winPanel.gameObject.SetActive(true);
	        gameWon = true;
	    }

        if (gameWon && Input.GetKeyDown(KeyCode.R))
            RestartGame();
	}

    public void RestartGame()
    {
        Application.LoadLevel(Application.loadedLevel);
    }
}
