using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class GerenciadorLevel1 : MonoBehaviour {

    public Transform[] prefabs;
    public Transform menuReiniciar;
    public float tempo;
    public float tempoDeEspera;
    public bool instanciarProxima;
    public int indicePrefabs = 0;
    public string proximoMapaEvolucao;
    public bool menuReiniciarAtivado = false;

    public int somaCorretas = 0;

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



        if (instanciarProxima == true && indicePrefabs != prefabs.Length)
        {
            Instantiate(prefabs[indicePrefabs], transform.position, transform.rotation);
            indicePrefabs++;
            instanciarProxima = false;
        }
        else
        {
            if (somaCorretas > 1 && indicePrefabs==prefabs.Length)
            {
                //Proximo nível..........................................
                print("Proximo level");

                LevelInicialParaLv2();
                Level2ParaLv3();
                Level3ParaLv4();

            }
            if(indicePrefabs==prefabs.Length){


            }
            

        }
    }

    private static void LevelInicialParaLv2()
    {
        if (Application.loadedLevelName == "Carnivoro")
        {
            Application.LoadLevel("Lv2 - Carnivoro");
        }
        if (Application.loadedLevelName == "Herbivoro")
        {
            Application.LoadLevel("Lv2 - Herbivoro");
        }
        if (Application.loadedLevelName == "Onivoro")
        {
            Application.LoadLevel("Lv2 - Onivoro");
        }
    }
    private static void Level2ParaLv3()
    {
        if (Application.loadedLevelName == "Lv2 - Carnivoro")
        {
            Application.LoadLevel("Lv3 - Carnivoro");
        }
        if (Application.loadedLevelName == "Lv2 - Herbivoro")
        {
            Application.LoadLevel("Lv3 - Herbivoro");
        }
        if (Application.loadedLevelName == "Lv2 - Onivoro")
        {
            Application.LoadLevel("Lv3 - Onivoro");
        }
    }
    private static void Level3ParaLv4()
    {
        if (Application.loadedLevelName == "Lv3 - Carnivoro")
        {
            Application.LoadLevel("Lv4 - Carnivoro");
        }
        if (Application.loadedLevelName == "Lv3 - Herbivoro")
        {
            Application.LoadLevel("Lv4 - Herbivoro");
        }
        if (Application.loadedLevelName == "Lv3 - Onivoro")
        {
            Application.LoadLevel("Lv4 - Onivoro");
        }
    }

}

