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

public class UIManager : MonoBehaviour
{
    public Slider scoreBar;
    public Image timer;
	private static UIManager instance = null;

	void Awake ()
	{
		if (instance == null)
		{
			instance = this;
		}
		else
		{
			Destroy(instance.gameObject);
			instance = this;
		}
	}

	public static UIManager getInstance ()
	{
		return instance;
	}


    /// <summary>
    /// 
    /// </summary>
    /// <param name="elapsedTime">Time elapsed since timer start (in seconds)</param>
    /// <param name="endTime">Total duration of the timer</param>
    public void UpdateTimer(float elapsedTime, float endTime)
    {
        timer.fillAmount = Mathf.Max(0f, 1 - (elapsedTime / endTime));
    }

    /// <summary>
    /// Update score bar with 'value'. 'value' is between 0 and 1.
    /// A value of 0.5 means Draw, 0 means maximum advantage for Player 2,
    /// 1 means maximum advantage for Player 1.
    /// </summary>
    /// <param name="value"></param>
    public void UpdateScoreBar(float value)
    {
        scoreBar.value += value;
    }

	public float GetScore(){
		return scoreBar.value;
	}
}
