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

public class SplashHandler : MonoBehaviour {
	public Animator fader;

	// Use this for initialization
	void Start () {
		DontDestroyOnLoad (gameObject);
		fader.SetTrigger ("Fade Out");
		Invoke ("Play", 3f);
	}

	public void FadeOut(){
		fader.SetTrigger ("Fade Out");
	}

	public void FadeIn(){
		fader.SetTrigger ("Fade In");
	}

	public void CrossFade(){
		StartCoroutine (CrossF ());
	}

	void Play(){
		StartCoroutine (Starting ());
	}

	IEnumerator Starting(){
		FadeIn ();
		yield return new WaitForSeconds (5f);
		SceneManager.LoadScene ("Main");
		FadeOut ();
	}

	IEnumerator CrossF(){
		FadeIn ();
		yield return new WaitForSeconds (1.5f);
		FadeOut ();
	}


	
	// Update is called once per frame
	void Update () {
		
	}
}
