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

public class TimeScore : MonoBehaviour {

	float mCurrentTime = 0;
	public bool finished = false;
	[SerializeField]
	Text PopUpText;
	private string OutputString;
	
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () 
	{	
		{
			mCurrentTime += Time.deltaTime;
		}
		string timeRemainingString = System.TimeSpan.FromSeconds((double)mCurrentTime).ToString();
		if(timeRemainingString.Length > 8)
		{
			OutputString = timeRemainingString.Substring(4,7);
		}
		else
		{
			OutputString = (timeRemainingString.Substring(4) + ".00");
		}		
	}
	
	void OnTriggerEnter2D(Collider2D other)
	{
		if(other.tag == "Player")
		{
			finished = true;
			PopUpText.text = string.Format("You did it in {0}", OutputString);	
		}
		
	}
}
