Example #1
0
    void Start()
    {
        try {
            arquivoGame = SaveControl.LoadArquivoJogo();
        } catch (Exception) {
            arquivoGame = new Persistente();
        }

        if (arquivoGame.iniciouGame)
        {
            cromossomosUsados = arquivoGame.cromossomos;

            this.AjustaArrayScore();
            this.Evolucao();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    caixas[(j + (i * 10))] = (GameObject)Instantiate(caixasPrefab, new Vector2(colunasPossiveis[cromossomosUsados[i].cromossomo[j]], 1.28f * (float)(j + (i * 10))), Quaternion.identity);
                }
            }

            //Iniciar sempre no centro
            Destroy(caixas[0]);
            caixas[0] = (GameObject)Instantiate(caixasPrefab, new Vector2(colunasPossiveis[1], 0), Quaternion.identity);
        }
        else
        {
            this.GerarPopulacaoInicial();

            for (int i = 0; i < 100; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    caixas[(j + (i * 10))] = (GameObject)Instantiate(caixasPrefab, new Vector2(colunasPossiveis[cromossomosUsados[i].cromossomo[j]], 1.28f * (float)(j + (i * 10))), Quaternion.identity);
                }
            }

            //Iniciar sempre no centro
            Destroy(caixas[0]);
            caixas[0] = (GameObject)Instantiate(caixasPrefab, new Vector2(colunasPossiveis[1], 0), Quaternion.identity);
        }

        this.VerificarPontuacao();
    }