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

public class Timer : MonoBehaviour {
    public Text timerText;

	private float timer;
    public float MAX;
    public bool start = false;
    public Constants.Colors state = Constants.Colors.NONE;

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		if (!start)
			return;

		timer -= Time.deltaTime;
        timerText.text = "Potion Burns in: "+ Math.Round(timer, 1).ToString();

		if (timer < 0f) {
			Controller.Instance.gameState = Controller.GameState.GAMEOVER;
			start = false;
		}
	}

	public void SetTimer(float t, Constants.Colors s) {
        if (s != state)
        {
            timer = t;
            start = true;
            state = s;
        }
	}
}
