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

public class TutorialPanel2 : TutorialPanel
{
    private Image panelImage;
    public Text text;
    public TutorialPanel3 tutorialPanel3;

    private void Awake()
    {
        panelImage = GetComponent<Image>();
    }

    protected override void OnEnable()
    {
        base.OnEnable();

        panelImage.CrossFadeAlpha(0.3f, 3f, false);
        SetAlpha(text, 0);
        StartCoroutine(ShowTextAfterSeconds(3f));
    }

    private IEnumerator ShowTextAfterSeconds(float seconds)
    {
        yield return new WaitForSeconds(seconds);

        float t = 0;
        while (t < 1)
        {
            SetAlpha(text, Mathf.Lerp(0, 1, t));
            t += Time.deltaTime;
            yield return null;
        }

        SetAlpha(pressAnyKey, 1);
    }

    public override void Dismiss()
    {
        tutorialPanel3.gameObject.SetActive(true);
        Destroy(gameObject);
    }
}
