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

public class IntroScript : MonoBehaviour {

	public GameObject[] pics;
	int i;
	bool isClickable=false;

	void Start () {
		i = 0;
		Invoke ("showNextImage", 1f);
	
	}

	void LoadNextLvl()
	{
		int index = SceneManager.GetActiveScene ().buildIndex;
		SceneManager.LoadScene (++index);
	}

	// Update is called once per frame
	void FixedUpdate () {
		if (Input.anyKey && isClickable) {
			showNextImage ();
		}
	
	}

	void showNextImage()
	{
		

		if (i < pics.Length) {
			
			isClickable = false;
			Invoke ("makeClickable", 1.5f);

			if (i != 0)
				pics [i - 1].SetActive (false);

			pics [i].SetActive (true);
		} else
			LoadNextLvl ();

		i++;
		//Invoke ("showNextImage",2f);
	}

	void makeClickable()
	{
		isClickable = true;
	}
}
