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

public class IntroInitiator : MonoBehaviour
{
    /// <summary>
    /// The time the font uses to fade
    /// </summary>
    public float FadeTime;
    public float RealTime;

    private Text text;

	// Use this for initialization
	void Start ()
	{
	    text = GetComponentInChildren<Text>();
	    Color color = text.color;
	    text.color = new Color(color.r, color.g, color.b, 0);
	    RealTime = 0;
	}

    void Update()
    {
        RealTime += Time.deltaTime;
        if (RealTime > 2 * FadeTime + 2f)
        {
            gameObject.SetActive(false);
            return;
        }
        Color color = text.color;
        if (RealTime < FadeTime)
        {
            color = new Color(color.r, color.g, color.b, color.a + 0.02f);
        }
        else if(RealTime > FadeTime + 2f)
        {
            color = new Color(color.r, color.g, color.b, color.a - 0.02f);
        }
        text.color = color;
    }

	
}
