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

public class GameOverGUI : MonoBehaviour 
{

    private PlayerController playerController;
    public GameObject gameOverPanel;
    public Text gameOverText;
    public Text gameOverMessageText;
    public Text finalScoreText;
    public Text customersText;
    public Text maitreDText;
    public Text waitstaffText;
    public Text chefsText;
    public Text managersText;
    public Text breakageBonusText;
    public string[] gameOverMessages;

    private int messageIndex = -1;

    void Awake()
    {
        playerController = FindObjectOfType<PlayerController>();
    }
    
	void Update () 
    {
        if (playerController.gameOver)
        {
            gameOverPanel.SetActive(true);

            if (playerController.isWinner)
            {
                gameOverText.text = "You Win!!!";
                gameOverMessageText.text = "The Restaurant Has Closed Permanently";
            }
            else
            {
                if (messageIndex == -1)
                {
                    messageIndex = Random.Range(0, gameOverMessages.Length);
                }
                gameOverText.text = "Game Over";
                gameOverMessageText.text = gameOverMessages[messageIndex];
            }
            finalScoreText.text = playerController.score.ToString("#,##0");
            customersText.text = playerController.GetKills(0).ToString("#,##0");
            maitreDText.text = playerController.GetKills(1).ToString("#,##0");
            waitstaffText.text = playerController.GetKills(2).ToString("#,##0");
            chefsText.text = playerController.GetKills(3).ToString("#,##0");
            managersText.text = playerController.GetKills(4).ToString("#,##0");
            breakageBonusText.text = playerController.breakagePoints.ToString("#,##0");


        }
	}
}
