using UnityEngine;
using System.Collections;
using System;

public class WtfManager : MonoBehaviour
{


    public CanvasGroup[] Steps;
    public CanvasGroup end;

    int stepIndex = 0;
    // Use this for initialization
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (stepIndex > 0 && Input.GetMouseButtonDown(0))
        {
            showNextTip();
        }
    }

    void OnFadeOut()
    {
        gameObject.SetActive(false);
    }

    void OnFadeIn()
    {
        showNextTip();
    }

    void showNextTip()
    {

        if (Steps.Length > stepIndex)
        {
            Steps[((stepIndex > 0) ? stepIndex - 1 : 0)].alpha = 0;
            Steps[stepIndex++].alpha = 1;
        }
        else if (end.alpha == 0)
        {
            Steps[stepIndex - 1].alpha = 0;
            end.alpha = 1;
        }
        else
        {
            end.alpha = 0;
            GetComponent<Animator>().Play("FADE_OUT");
        }
    }

    internal void FadeIn()
    {
        stepIndex = 0;
        GetComponent<Animator>().SetFloat("Speed", 2.0f);
        gameObject.SetActive(true);
        GetComponent<Animator>().Play("FADE_IN");
    }
}
