using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class TransitionToMain : MonoBehaviour
{

    public bool playersReady;

    public float loadTime;

    public Animator fadeScreenAnim;

    // Use this for initialization
    void Start()
    {
        playersReady = false;

        if (fadeScreenAnim == null)
            Debug.LogError(gameObject.GetComponent<TransitionToMain>() + " is missing "
                           + gameObject.GetComponent<Animator>());
        

    }

    // Update is called once per frame
    void Update()
    {
        fadeScreenAnim.SetBool("readyToFadeOut", playersReady);

        playersReady |= Input.GetKeyDown(KeyCode.Space);


        if(playersReady)
        {
            loadTime -= Time.deltaTime;
           
           

            if (loadTime <= 0)
                SceneManager.LoadScene("Main"); 

        }
		
	}

}
