using UnityEngine;
using Shapes;

public class ProgressDisplay : MonoBehaviour
{
	public Transform puck;
	public float displayDuration = 3f;

	private DoubleCenter doubleCenter;
	private BigAir bigAir;
	private LittleKing littleKing;

	private float displayUntil;

	void Update()
    {
		if (puck == null)
			return;

		if (puck.position.x >= 12.5f && puck.position.y >= 14)
		{
			displayUntil = displayDuration + Time.time;
		}
    }

	public void ImmediateDraw()
	{
		if (Time.time > displayUntil)
		{
			Color darkGray = new Color(0.2f, 0.2f, 0.2f, 1.0f);
			Vector3 corner = new Vector3(14.5f, 15f);
			Draw.Triangle(corner, corner + new Vector3(-1, 1), corner + Vector3.up, darkGray);
			return;
		}

		string list = "";
		int count = 0;

		if(doubleCenter.isAchieved())
		{
			list += "\nDouble-Center";
			count++;
		}
		if (bigAir.isAchieved())
		{
			list += "\nBig Air";
			count++;
		}
		if (littleKing.isAchieved())
		{
			list += "\nLittle King";
			count++;
		}

		string msg = count + "/3" + list;
		Vector3 pos = new Vector3(8f, 15f);
		Draw.Text(pos, msg, TextAlign.TopLeft, fontSize: 8, Color.white);
	}

	private void Start()
	{		
		doubleCenter = GetComponent<DoubleCenter>();
		bigAir = GetComponent<BigAir>();
		littleKing = GetComponent<LittleKing>();
	}
}
