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

public class GameTimer : MonoBehaviour {

	[Header ("GAME TIMER")]
	public float timeLeft;
	public float countdownTimer;
    public bool gameOver, p1Wins, p2Wins, tie;

    private void Start()
    {
        gameOver = false;
    }
    // Update is called once per frame
    void Update () {

		timeLeft = Mathf.Round(countdownTimer);

			if (countdownTimer >= 0)
				countdownTimer-= Time.deltaTime;

        Debug.Log(timeLeft);

		if (countdownTimer <= 0)
        {
            gameOver = true;
        }	

        if (gameOver)
        {
            if (gameObject.GetComponent<Score>().p1Points > gameObject.GetComponent<Score>().p2Points)
            {
                p1Wins = true;

            } else if (gameObject.GetComponent<Score>().p1Points < gameObject.GetComponent<Score>().p2Points)
            {
                p2Wins = true;
            } else
            {
                tie = true;
            }

        }

        
		
	}




		


}
