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

public class StartScreen : MonoBehaviour
{
	[SerializeField]
	private Text text;

	[SerializeField]
	private Image image;

	[SerializeField]
	private GameController gameController;

	private bool keyPressed = false;

	// Use this for initialization
	void Start()
	{
		StartCoroutine(BlinkText());
	}

	void Update()
	{
		if(Input.anyKey)
			keyPressed = true;
	}

	IEnumerator BlinkText()
	{
		while(!keyPressed)
		{
			text.CrossFadeAlpha(1, 1, true);

			yield return new WaitForSeconds(1f);

			text.CrossFadeAlpha(0, 1, true);

			yield return new WaitForSeconds(1f);
		}

		image.CrossFadeAlpha(0, 0.5f, true);

		yield return new WaitForSeconds(0.5f);

		gameController.StartGame();

		StopCoroutine(BlinkText());

		gameObject.SetActive(false);
	}
}
