using UnityEngine;
using System.Collections;

public class Gerenciador : MonoBehaviour {

    public Transform[] prefabs;
    public float tempo;
    public float tempoDeEspera;
    public bool instanciarProxima;
    public int indicePrefabs=0;

    public int somaHerbivoros = 0;
    public int somaCarnivoros = 0;

    public int somaCorretas = 0;


	void Start () {
        instanciarProxima = true;
	}
    void Update()
    {

        

        if(instanciarProxima==true && indicePrefabs!=prefabs.Length){
            Instantiate(prefabs[indicePrefabs], transform.position, transform.rotation);
            instanciarProxima = false;
        }
        else
        {
            if(somaHerbivoros>somaCarnivoros && indicePrefabs==prefabs.Length){

                Application.LoadLevel("Herbivoro");
                //Ir para a cena herbivoro

            }
            else if (somaCarnivoros > somaHerbivoros && indicePrefabs == prefabs.Length)
            {
                //Ir para a cena carnivoro
                Application.LoadLevel("Carnivoro");
            }
            else if (somaHerbivoros == somaCarnivoros && somaCarnivoros != 0 && indicePrefabs == prefabs.Length)
            {
                Application.LoadLevel("Onivoro");
                //Ir para cena onivoro
            }

        }
    }
    /*public void RandomizarPergunta()
    {
        Esperar();
        int numPrefab = Random.Range(0, prefabs.Length);
        Instantiate(prefabs[numPrefab], transform.position, transform.rotation);
    }*/

    IEnumerator Esperar()
    {
        yield return new WaitForSeconds(2);


    }
    



	
}
