private void ComecaLab()
    {
        celulas = new Celula[linha, coluna];

        for (int l = 0; l < linha; l++)
        {
            for (int c = 0; c < coluna; c++)
            {
                celulas[l, c] = new Celula();

                if (c == 0)
                {
                    celulas[l, c].paredeEsquerda = Instantiate(parede, new Vector3(l * tamanho, 0, (c * tamanho) - (tamanho / 2f)), Quaternion.identity) as GameObject;
                }

                celulas[l, c].paredeDireita = Instantiate(parede, new Vector3(l * tamanho, 0, (c * tamanho) + (tamanho / 2f)), Quaternion.identity) as GameObject;

                if (l == 0)
                {
                    celulas[l, c].paredeCima = Instantiate(parede, new Vector3((l * tamanho) - (tamanho / 2f), 0, c * tamanho), Quaternion.identity) as GameObject;
                    celulas[l, c].paredeCima.transform.Rotate(Vector3.up * 90f);
                }

                celulas[l, c].paredeBaixo = Instantiate(parede, new Vector3((l * tamanho) + (tamanho / 2f), 0, c * tamanho), Quaternion.identity) as GameObject;
                celulas[l, c].paredeBaixo.transform.Rotate(Vector3.up * 90f);
            }
        }
    }
Ejemplo n.º 2
0
        private void InicializarCelulas()
        {
            Campo = new Celula[_linhas, _colunas];

            for (var linha = 0; linha < _linhas; linha++)
                for (var coluna = 0; coluna < _colunas; coluna++)
                    Campo[linha, coluna] = new Celula();
        }
Ejemplo n.º 3
0
        public bool Direita(Celula[,] matriz, ref int score)
        {
            bool isValid = false;

            for (int i = 0; i < 4; i++)
            {
                //Soma entre células
                for (int j = 3; j > 0; j--)
                {
                    if (!matriz[i, j].isEmpty && matriz[i, j - 1].valor == matriz[i, j].valor)
                    {
                        matriz[i, j].valor += matriz[i, j - 1].valor;
                        matriz[i, j - 1]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (j > 1 && !matriz[i, j].isEmpty && matriz[i, j - 1].isEmpty && matriz[i, j - 2].valor == matriz[i, j].valor)
                    {
                        matriz[i, j].valor += matriz[i, j - 2].valor;
                        matriz[i, j - 2]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (j > 2 && !matriz[i, j].isEmpty && matriz[i, j - 1].isEmpty && matriz[i, j - 2].isEmpty && matriz[i, j - 3].valor == matriz[i, j].valor)
                    {
                        matriz[i, j].valor += matriz[i, j - 3].valor;
                        matriz[i, j - 3]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                }
                //Deslocamento de células para células vazias
                for (int j = 3; j > 0; j--)
                {
                    if (matriz[i, j].isEmpty && !matriz[i, j - 1].isEmpty)
                    {
                        matriz[i, j]     = matriz[i, j - 1];
                        matriz[i, j - 1] = new Celula();
                        isValid          = true;
                    }
                    else if (j > 1 && matriz[i, j].isEmpty && matriz[i, j - 1].isEmpty && !matriz[i, j - 2].isEmpty)
                    {
                        matriz[i, j]     = matriz[i, j - 2];
                        matriz[i, j - 2] = new Celula();
                        isValid          = true;
                    }
                    else if (j > 2 && matriz[i, j].isEmpty && matriz[i, j - 1].isEmpty && matriz[i, j - 2].isEmpty && !matriz[i, j - 3].isEmpty)
                    {
                        matriz[i, j]     = matriz[i, j - 3];
                        matriz[i, j - 3] = new Celula();
                        isValid          = true;
                    }
                }
            }
            return(isValid);
        }
Ejemplo n.º 4
0
        public bool Baixo(Celula[,] matriz, ref int score)
        {
            bool isValid = false;

            for (int j = 0; j < 4; j++)
            {
                //Soma entre células
                for (int i = 3; i > 0; i--)
                {
                    if (!matriz[i, j].isEmpty && matriz[i, j].valor == matriz[i - 1, j].valor)
                    {
                        matriz[i, j].valor += matriz[i - 1, j].valor;
                        matriz[i - 1, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (i > 1 && !matriz[i, j].isEmpty && matriz[i - 1, j].isEmpty && matriz[i, j].valor == matriz[i - 2, j].valor)
                    {
                        matriz[i, j].valor += matriz[i - 2, j].valor;
                        matriz[i - 2, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (i > 2 && !matriz[i, j].isEmpty && matriz[i - 1, j].isEmpty && matriz[i - 2, j].isEmpty && matriz[i, j].valor == matriz[i - 3, j].valor)
                    {
                        matriz[i, j].valor += matriz[i - 3, j].valor;
                        matriz[i - 3, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                }
                //Deslocamento células vazias
                for (int i = 3; i > 0; i--)
                {
                    if (matriz[i, j].isEmpty && !matriz[i - 1, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i - 1, j];
                        matriz[i - 1, j] = new Celula();
                        isValid          = true;
                    }
                    else if (i > 1 && matriz[i, j].isEmpty && matriz[i - 1, j].isEmpty && !matriz[i - 2, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i - 2, j];
                        matriz[i - 2, j] = new Celula();
                        isValid          = true;
                    }
                    else if (i > 2 && matriz[i, j].isEmpty && matriz[i - 1, j].isEmpty && matriz[i - 2, j].isEmpty && !matriz[i - 3, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i - 3, j];
                        matriz[i - 3, j] = new Celula();
                        isValid          = true;
                    }
                }
            }
            return(isValid);
        }
Ejemplo n.º 5
0
        public bool Cima(Celula[,] matriz, ref int score)
        {
            bool isValid = false;

            for (int j = 0; j < 4; j++)
            {
                //Soma entre células
                for (int i = 0; i < 3; i++)
                {
                    if (!matriz[i, j].isEmpty && matriz[i, j].valor == matriz[i + 1, j].valor)
                    {
                        matriz[i, j].valor += matriz[i + 1, j].valor;
                        matriz[i + 1, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (i < 2 && !matriz[i, j].isEmpty && matriz[i + 1, j].isEmpty && matriz[i, j].valor == matriz[i + 2, j].valor)
                    {
                        matriz[i, j].valor += matriz[i + 2, j].valor;
                        matriz[i + 2, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                    else if (i < 1 && !matriz[i, j].isEmpty && matriz[i + 1, j].isEmpty && matriz[i + 2, j].isEmpty && matriz[i, j].valor == matriz[i + 3, j].valor)
                    {
                        matriz[i, j].valor += matriz[i + 3, j].valor;
                        matriz[i + 3, j]    = new Celula();
                        score  += matriz[i, j].valor;
                        isValid = true;
                    }
                }
                //Deslocamento de células vazias
                for (int i = 0; i < 3; i++)
                {
                    if (matriz[i, j].isEmpty && !matriz[i + 1, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i + 1, j];
                        matriz[i + 1, j] = new Celula();
                        isValid          = true;
                    }
                    else if (i < 2 && matriz[i, j].isEmpty && matriz[i + 1, j].isEmpty && !matriz[i + 2, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i + 2, j];
                        matriz[i + 2, j] = new Celula();
                        isValid          = true;
                    }
                    else if (i < 1 && matriz[i, j].isEmpty && matriz[i + 1, j].isEmpty && matriz[i + 2, j].isEmpty && !matriz[i + 3, j].isEmpty)
                    {
                        matriz[i, j]     = matriz[i + 3, j];
                        matriz[i + 3, j] = new Celula();
                        isValid          = true;
                    }
                }
            }
            return(isValid);
        }
Ejemplo n.º 6
0
    void Start()
    {
        grid     = new Celula[largura, altura];
        novaGrid = new Celula[largura, altura];

        foreach (GameObject b in botoes)
        {
            b.SetActive(false);
        }

        StartCoroutine(AutoPlay());
    }
Ejemplo n.º 7
0
        public Tabuleiro()
        {
            celulasTabuleiro = new Celula[3, 3];

            for (int y = 0; y < celulasTabuleiro.GetLength(1); y++)
            {
                for (int x = 0; x < celulasTabuleiro.GetLength(0); x++)
                {
                    celulasTabuleiro[x, y] = new Celula();
                }
            }

            jogadorAtual = Jogador.X;
        }
Ejemplo n.º 8
0
        public Grade(int tamX, int tamY)
        {
            this.pTamanhoX          = tamX;
            this.pTamanhoY          = tamY;
            this.pQuantidadeCelulas = tamX * tamY;

            if (tamX > 0 && tamY > 0)
            {
                this.pCelulas = new Celula[tamX, tamY];

                for (int i = 0; i < tamX; i++)
                {
                    for (int j = 0; j < tamY; j++)
                    {
                        this.pCelulas[i, j] = new Celula(this, i, j);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public Game()
        {
            matriz = new Celula[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    matriz[i, j] = new Celula();
                }
            }

            valoresInseridos = new int[4] {
                2, 2, 2, 4
            };
            score = 0;

            impressão = new Impressão();
            comandos  = new Comandos();
            rnd       = new Random();
            InsereNumeros();
            InsereNumeros();
        }
Ejemplo n.º 10
0
    /*public void Start() {
     *      DontDestroyOnLoad (gameObject);
     * }*/

    public void Init()
    {
        grid           = new Celula[MAX_SIZE, MAX_SIZE];
        playerPosition = new Vector3();
        playerRotation = 0;

        for (int i = 0; i < MAX_SIZE; i++)
        {
            for (int j = 0; j < MAX_SIZE; j++)
            {
                GameObject cell = Instantiate(
                    baseCell,
                    new Vector3(cellSide * i, -Mathf.Sqrt(3) / 3.0f, cellSide * j),
                    Quaternion.identity) as GameObject;
                cell.transform.Rotate(new Vector3(270.0f, 0.0f, 0.0f));
                cell.transform.parent = this.transform;
                grid[i, j]            = new Celula();
                grid[i, j].setGameObject(cell);
            }
        }

        instance = this;
    }
Ejemplo n.º 11
0
    void Start()
    {
        int     x, y;
        int     xOffset = 0, yOffset = 0;
        Vector3 pos;

        populacao      = new Celula[linha, coluna];
        proximaGeracao = new bool[linha, coluna];

        for (x = 0; x < linha; x++)
        {
            for (y = 0; y < coluna; y++)
            {
                pos                  = new Vector3(origem.position.x + xOffset, origem.position.y, origem.position.z + yOffset);
                populacao[y, x]      = Instantiate(celula, pos, Quaternion.identity) as Celula;
                proximaGeracao[y, x] = false;
                yOffset++;
            }
            xOffset++;
            yOffset = 0;
        }
        GerarPopulacao();
    }
 protected Algoritmo(Celula[,] celulas) : base()
 {
     this.celulas = celulas;
     linha        = celulas.GetLength(0);
     coluna       = celulas.GetLength(1);
 }
Ejemplo n.º 13
0
 protected Labirinto(Celula[,] _matrizCelulas) : base()
 {
     this.matrizCelulas = _matrizCelulas;
     linhas             = _matrizCelulas.GetLength(0);
     colunas            = _matrizCelulas.GetLength(1);
 }
Ejemplo n.º 14
0
        public void Test()
        {
            Tabuleiro t = new Tabuleiro();

            t.RegisterObserver(this);

            // Verifica estado inicial do tabuleiro (deve ser vazio)
            Celula[,] celulas = t.GetCelulas();
            for (int y = 0; y < celulas.GetLength(1); y++)
            {
                for (int x = 0; x < celulas.GetLength(0); x++)
                {
                    if (celulas[x, y].GetJogada() != null)
                    {
                        throw new Exception("Nenhuma jogada deve existir ao início da execução");
                    }
                }
            }

            // Verifica primeiro jogador a jogar (deve ser X)
            if (t.GetProximo() != Jogador.X)
            {
                throw new Exception("O jogador X deve ser sempre o primeiro a jogar");
            }

            // Verifica vitória (não deve existir)
            if (t.GetVitoria() != null)
            {
                throw new Exception("Não deve existir vitória ao início da execução");
            }

            // Efetua e verifica a primeira jogada na posição (1,1), e verifica o próximo jogador a jogar (deve ser O)
            notificado = false;
            if (!t.Jogar(1, 1))
            {
                throw new Exception("Uma primeira jogada em (1,1) ao início da execução deve ser factível");
            }
            if (t.GetCelulas()[1, 1].GetJogada() != Jogador.X)
            {
                throw new Exception("A primeira jogada, em (1,1), não foi efetivada para o jogador X");
            }
            if (t.GetProximo() != Jogador.O)
            {
                throw new Exception("Após a primeira jogada, o jogador O deve ser o próximo a jogar");
            }
            if (!notificado)
            {
                throw new Exception("Após a primeira jogada, a notificação de mudança não foi disparada");
            }

            // Efetua e verifica a segunda jogada na posição (2,1), e verifica o próximo jogador a jogar (deve ser X)
            notificado = false;
            if (!t.Jogar(2, 1))
            {
                throw new Exception("Uma segunda jogada em (2,1) deve ser factível");
            }
            if (t.GetCelulas()[2, 1].GetJogada() != Jogador.O)
            {
                throw new Exception("A segunda jogada, em (2,1), não foi efetivada para o jogador O");
            }
            if (t.GetProximo() != Jogador.X)
            {
                throw new Exception("Após a segunda jogada, o jogador X deve ser o próximo a jogar");
            }
            if (!notificado)
            {
                throw new Exception("Após a segunda jogada, a notificação de mudança não foi disparada");
            }

            // Efetua e verifica a terceira jogada na posição (0,0), e verifica o próximo jogador a jogar (deve ser O)
            notificado = false;
            if (!t.Jogar(0, 0))
            {
                throw new Exception("Uma terceira jogada em (0,0) deve ser factível");
            }
            if (t.GetCelulas()[0, 0].GetJogada() != Jogador.X)
            {
                throw new Exception("A terceira jogada, em (0,0), não foi efetivada para o jogador X");
            }
            if (t.GetProximo() != Jogador.O)
            {
                throw new Exception("Após a terceira jogada, o jogador O deve ser o próximo a jogar");
            }
            if (!notificado)
            {
                throw new Exception("Após a terceira jogada, a notificação de mudança não foi disparada");
            }

            // Efetua e verifica a quarta jogada na posição (2,2), e verifica o próximo jogador a jogar (deve ser X)
            notificado = false;
            if (!t.Jogar(2, 2))
            {
                throw new Exception("Uma quarta jogada em (2,2) deve ser factível");
            }
            if (t.GetCelulas()[2, 2].GetJogada() != Jogador.O)
            {
                throw new Exception("A quarta jogada, em (2,2), não foi efetivada para o jogador O");
            }
            if (t.GetProximo() != Jogador.X)
            {
                throw new Exception("Após a quarta jogada, o jogador X deve ser o próximo a jogar");
            }
            if (!notificado)
            {
                throw new Exception("Após a quarta jogada, a notificação de mudança não foi disparada");
            }

            // Tenta jogar novamente em posições já jogadas
            notificado = false;
            if (t.Jogar(1, 1))
            {
                throw new Exception("Uma nova jogada na posição (1,1) não deve ser possível");
            }
            if (t.Jogar(2, 1))
            {
                throw new Exception("Uma nova jogada na posição (2,1) não deve ser possível");
            }
            if (t.Jogar(0, 0))
            {
                throw new Exception("Uma nova jogada na posição (0,0) não deve ser possível");
            }
            if (t.Jogar(2, 2))
            {
                throw new Exception("Uma nova jogada na posição (2,2) não deve ser possível");
            }
            if (notificado)
            {
                throw new Exception("Nas jogadas inválidas, a notificação de mudança foi disparada");
            }

            // Efetua e verifica a quarta jogada na posição (1,0), e verifica o próximo jogador a jogar (deve ser O)
            notificado = false;
            if (!t.Jogar(1, 0))
            {
                throw new Exception("Uma quinta jogada em (1,0) deve ser factível");
            }
            if (t.GetCelulas()[1, 0].GetJogada() != Jogador.X)
            {
                throw new Exception("A quinta jogada, em (1,0), não foi efetivada para o jogador X");
            }
            if (t.GetProximo() != Jogador.O)
            {
                throw new Exception("Após a quinta jogada, o jogador O deve ser o próximo a jogar");
            }
            if (!notificado)
            {
                throw new Exception("Após a quinta jogada, a notificação de mudança não foi disparada");
            }

            // Efetua e verifica a quarta jogada na posição (2,0), que deve resultar em vitória para o jogador O
            notificado = false;
            if (!t.Jogar(2, 0))
            {
                throw new Exception("Uma sexta jogada em (2,0) deve ser factível");
            }
            if (t.GetCelulas()[2, 0].GetJogada() != Jogador.O)
            {
                throw new Exception("A sexta jogada, em (2,0), não foi efetivada para o jogador O");
            }
            if (t.GetVitoria() != Jogador.O)
            {
                throw new Exception("Após a sexta jogada, o jogador O deve ser o vitorioso");
            }
            if (!notificado)
            {
                throw new Exception("Após a sexta jogada, a notificação de mudança não foi disparada");
            }

            // Confere o estado final do tabuleiro
            if (t.GetCelulas()[0, 0].GetJogada() != Jogador.X)
            {
                throw new Exception("Estado final do tabuleiro inválido em (0,0)");
            }
            if (t.GetCelulas()[0, 1].GetJogada() != null)
            {
                throw new Exception("Estado final do tabuleiro inválido em (0,1)");
            }
            if (t.GetCelulas()[0, 2].GetJogada() != null)
            {
                throw new Exception("Estado final do tabuleiro inválido em (0,2)");
            }
            if (t.GetCelulas()[1, 0].GetJogada() != Jogador.X)
            {
                throw new Exception("Estado final do tabuleiro inválido em (1,0)");
            }
            if (t.GetCelulas()[1, 1].GetJogada() != Jogador.X)
            {
                throw new Exception("Estado final do tabuleiro inválido em (1,1)");
            }
            if (t.GetCelulas()[1, 2].GetJogada() != null)
            {
                throw new Exception("Estado final do tabuleiro inválido em (1,2)");
            }
            if (t.GetCelulas()[2, 0].GetJogada() != Jogador.O)
            {
                throw new Exception("Estado final do tabuleiro inválido em (2,0)");
            }
            if (t.GetCelulas()[2, 1].GetJogada() != Jogador.O)
            {
                throw new Exception("Estado final do tabuleiro inválido em (2,1)");
            }
            if (t.GetCelulas()[2, 2].GetJogada() != Jogador.O)
            {
                throw new Exception("Estado final do tabuleiro inválido em (2,2)");
            }

            Console.WriteLine("Teste executado com sucesso");
        }
Ejemplo n.º 15
0
    public Sala()
    {
        //Instanciando a Randomizacao
        System.Random tamanho = new System.Random(Guid.NewGuid().GetHashCode());
        // Gerando valores aleatorios de coordenada x e y, para instanciar o vector.
        int    x           = tamanho.Next(Config.tamanhoMinSala.x, Config.tamanhoMaxSala.x);
        int    y           = tamanho.Next(Config.tamanhoMinSala.y, Config.tamanhoMaxSala.y);
        Vetor2 tamanhoSala = new Vetor2(x, y);

        Celula[,] sala   = new Celula[tamanhoSala.x, tamanhoSala.y];
        this.tamanhoSala = tamanhoSala;
        int numeroPortas = tamanho.Next(Config.numeroMinPortas, Config.numeroMaxPortas);

        this.numeroPortas = numeroPortas;
        //Preenchendo a Sala;
        for (int i = 0; i < tamanhoSala.y; i++)
        {
            for (int j = 0; j < tamanhoSala.x; j++)
            {
                if (j == 0 || i == 0 || j == (tamanhoSala.x - 1) || i == (tamanhoSala.y - 1))
                {
                    Vetor2 coordPreenchida = new Vetor2(j, i);
                    Celula celulaPreencheu = new Celula(coordPreenchida, "pSala");
                    //adicionando subtipo*
                    if (j == 0 && i == 0)
                    {
                        celulaPreencheu.subTipoCelula = "quinaECp";
                    }
                    if (j == 0 && i == (tamanhoSala.y - 1))
                    {
                        celulaPreencheu.subTipoCelula = "quinaEBp";
                    }
                    if (j == 0 && i != (tamanhoSala.y - 1) && i != 0)
                    {
                        celulaPreencheu.subTipoCelula = "esquerdap";
                    }
                    if (j == (tamanhoSala.x - 1) && i == 0)
                    {
                        celulaPreencheu.subTipoCelula = "quinaDCp";
                    }
                    if (j == (tamanhoSala.x - 1) && i == (tamanhoSala.y - 1))
                    {
                        celulaPreencheu.subTipoCelula = "quinaDBp";
                    }
                    if (j == (tamanhoSala.x - 1) && i != (tamanhoSala.y - 1) && i != 0)
                    {
                        celulaPreencheu.subTipoCelula = "direitap";
                    }
                    if (i == 0 && j != 0 && j != (tamanhoSala.x - 1))
                    {
                        celulaPreencheu.subTipoCelula = "cimap";
                    }
                    if (i == tamanhoSala.y - 1 && j != 0 && j != (tamanhoSala.x - 1))
                    {
                        celulaPreencheu.subTipoCelula = "baixop";
                    }

                    celulaPreencheu.coordCelulaSala = coordPreenchida;
                    sala[j, i] = celulaPreencheu;
                }
                else
                {
                    Vetor2 coordPreenchida = new Vetor2(j, i);
                    Celula celulaPreencheu = new Celula(coordPreenchida, "chao");
                    celulaPreencheu.coordCelulaSala = coordPreenchida;
                    sala[j, i] = celulaPreencheu;
                }
            }
        }
        //Adicionando Portas.
        for (int i = 0; i < numeroPortas; i++)
        {
            int    xPorta           = tamanho.Next(2, tamanhoSala.x - 3);
            int    yPorta           = tamanho.Next(2, tamanhoSala.y - 3);
            int    ladoPorta        = tamanho.Next(1, 5);
            Vetor2 coordPreenchida2 = new Vetor2(0, 0);
            string subtipo          = "";
            switch (ladoPorta)
            {
            case 1:
                coordPreenchida2 = new Vetor2(0, yPorta);
                subtipo          = "esquerdap";
                break;

            case 2:
                coordPreenchida2 = new Vetor2(tamanhoSala.x - 1, yPorta);
                subtipo          = "direitap";
                break;

            case 3:
                coordPreenchida2 = new Vetor2(xPorta, 0);
                subtipo          = "cimap";
                break;

            case 4:
                coordPreenchida2 = new Vetor2(xPorta, tamanhoSala.y - 1);
                subtipo          = "baixop";
                break;
            }

            Celula celulaPreencheu = new Celula(coordPreenchida2, "porta");
            celulaPreencheu.ehPorta         = true;
            celulaPreencheu.subTipoCelula   = subtipo;
            celulaPreencheu.coordCelulaSala = coordPreenchida2;
            sala[coordPreenchida2.x, coordPreenchida2.y] = celulaPreencheu;
        }



        this.sala = sala;
    }
Ejemplo n.º 16
0
 public HuntAndKill(Celula[,] mazeCells) : base(mazeCells)
 {
 }
 public Elimina(Celula[,] celulas) : base(celulas)
 {
 }
Ejemplo n.º 18
0
 private Campo(int tamanhoX, int tamanhoY, int numeroDeBombas)
 {
     celulas             = new Celula[tamanhoX, tamanhoY];
     this.numeroDeBombas = numeroDeBombas;
 }
Ejemplo n.º 19
0
 private void Inicializa()
 {
     qtdCreditos = 0;
     grade = new Celula[6, 7];
     normais = new List<Disciplina>();
     especiais = new List<Disciplina>();
 }
Ejemplo n.º 20
0
 public void ImprimeMatriz(Celula[,] matriz, int score)
 {
     Console.Clear();
     Console.WriteLine("SCORE: {0}\n\n", score);
     for (int i = 0; i < 4; i++)
     {
         Console.WriteLine("+--------+--------+--------+--------+");
         Console.WriteLine("|        |        |        |        |");
         if (matriz[i, 0].valor < 10)
         {
             Console.Write("|      {0} |", matriz[i, 0].valor != 0 ? matriz[i, 0].valor.ToString() : " ");
         }
         else if (matriz[i, 0].valor < 100)
         {
             Console.Write("|     {0} |", matriz[i, 0].valor);
         }
         else if (matriz[i, 0].valor < 1000)
         {
             Console.Write("|    {0} |", matriz[i, 0].valor);
         }
         else if (matriz[i, 0].valor < 10000)
         {
             Console.Write("|   {0} |", matriz[i, 0].valor);
         }
         else
         {
             Console.Write("|  {0} |", matriz[i, 0].valor);
         }
         if (matriz[i, 1].valor < 10)
         {
             Console.Write("      {0} |", matriz[i, 1].valor != 0 ? matriz[i, 1].valor.ToString() : " ");
         }
         else if (matriz[i, 1].valor < 100)
         {
             Console.Write("     {0} |", matriz[i, 1].valor);
         }
         else if (matriz[i, 1].valor < 1000)
         {
             Console.Write("    {0} |", matriz[i, 1].valor);
         }
         else if (matriz[i, 1].valor < 10000)
         {
             Console.Write("   {0} |", matriz[i, 1].valor);
         }
         else
         {
             Console.Write("  {0} |", matriz[i, 1].valor);
         }
         if (matriz[i, 2].valor < 10)
         {
             Console.Write("      {0} |", matriz[i, 2].valor != 0 ? matriz[i, 2].valor.ToString() : " ");
         }
         else if (matriz[i, 2].valor < 100)
         {
             Console.Write("     {0} |", matriz[i, 2].valor);
         }
         else if (matriz[i, 2].valor < 1000)
         {
             Console.Write("    {0} |", matriz[i, 2].valor);
         }
         else if (matriz[i, 2].valor < 10000)
         {
             Console.Write("   {0} |", matriz[i, 2].valor);
         }
         else
         {
             Console.Write("  {0} |", matriz[i, 2].valor);
         }
         if (matriz[i, 3].valor < 10)
         {
             Console.Write("      {0} |", matriz[i, 3].valor != 0 ? matriz[i, 3].valor.ToString() : " ");
         }
         else if (matriz[i, 3].valor < 100)
         {
             Console.Write("     {0} |", matriz[i, 3].valor);
         }
         else if (matriz[i, 3].valor < 1000)
         {
             Console.Write("    {0} |", matriz[i, 3].valor);
         }
         else if (matriz[i, 3].valor < 10000)
         {
             Console.Write("   {0} |", matriz[i, 3].valor);
         }
         else
         {
             Console.Write("  {0} |", matriz[i, 3].valor);
         }
         Console.WriteLine("\n|        |        |        |        |");
     }
     Console.WriteLine("+--------+--------+--------+--------+");
     Console.WriteLine("\n\n Enter = Reinicia\t Esc = Sair\t← = Esquerda\t→ = Direita\t↑ = Cima\t↓=Baixo\t");
 }
Ejemplo n.º 21
0
    private void InicializarLabirinto()
    {
        matrizCelulas = new Celula[Linhas, Colunas];

        for (int l = 0; l < Linhas; l++)
        {
            for (int c = 0; c < Colunas; c++)
            {
                matrizCelulas [l, c] = new Celula();


                //adicionar os PISOS em todas as posições da matriz
                matrizCelulas[l, c].piso      = Instantiate(Piso, new Vector3(l * escalaGameObj, -0.25f, c * escalaGameObj), Quaternion.identity) as GameObject;
                matrizCelulas[l, c].piso.name = "Piso " + l + "," + c;
                matrizCelulas[l, c].piso.transform.Rotate(Vector3.right, 90f);
                matrizCelulas[l, c].piso.transform.SetParent(Labirinto);
                matrizCelulas[l, c].piso.tag = "Piso";
                matrizCelulas[l, c].piso.GetComponent <Renderer>().material.color = new Color(0.9f, 0.9f, 0.9f);

                //Preencher todo o labirinto inicial
                //fazendo as paredes externas e preenchendo todas as células
                //com paredes fechando toda célula por completo

                if (c == 0)
                {
                    matrizCelulas[l, c].paredeOeste       = Instantiate(Parede, new Vector3(l * escalaGameObj, 0.8f, (c * escalaGameObj) - (escalaGameObj / 2f)), Quaternion.identity) as GameObject;
                    matrizCelulas[l, c].paredeOeste.name  = "Parede (Oeste) " + l + "," + c;
                    matrizCelulas[l, c].paredeOeste.tag   = "Parede";
                    matrizCelulas[l, c].paredeOeste.layer = LayerMask.NameToLayer("Parede");
                    matrizCelulas[l, c].paredeOeste.GetComponent <Renderer>().material.SetColor("_Color", new Vector4(0.05f, 0.05f, 0.05f));
                    matrizCelulas[l, c].paredeOeste.GetComponent <Renderer>().material.SetTexture("wall", default);
                    matrizCelulas[l, c].paredeOeste.transform.SetParent(Labirinto);
                }

                matrizCelulas[l, c].paredeLeste       = Instantiate(Parede, new Vector3(l * escalaGameObj, 0.8f, (c * escalaGameObj) + (escalaGameObj / 2f)), Quaternion.identity) as GameObject;
                matrizCelulas[l, c].paredeLeste.name  = "Parede (Leste) " + l + "," + c;
                matrizCelulas[l, c].paredeLeste.tag   = "Parede";
                matrizCelulas[l, c].paredeLeste.layer = LayerMask.NameToLayer("Parede");
                matrizCelulas[l, c].paredeLeste.GetComponent <Renderer>().material.SetColor("_Color", new Vector4(0.05f, 0.05f, 0.05f));
                matrizCelulas[l, c].paredeLeste.GetComponent <Renderer>().material.SetTexture("wall", default);
                matrizCelulas[l, c].paredeLeste.transform.SetParent(Labirinto);

                if (l == 0)
                {
                    matrizCelulas[l, c].paredeNorte      = Instantiate(Parede, new Vector3((l * escalaGameObj) - (escalaGameObj / 2f), 0.8f, c * escalaGameObj), Quaternion.identity) as GameObject;
                    matrizCelulas[l, c].paredeNorte.name = "Parede (Norte) " + l + "," + c;
                    matrizCelulas[l, c].paredeNorte.transform.Rotate(Vector3.up * 90f);
                    matrizCelulas[l, c].paredeNorte.tag   = "Parede";
                    matrizCelulas[l, c].paredeNorte.layer = LayerMask.NameToLayer("Parede");
                    matrizCelulas[l, c].paredeNorte.GetComponent <Renderer>().material.SetColor("_Color", new Vector4(0.05f, 0.05f, 0.05f));
                    matrizCelulas[l, c].paredeNorte.GetComponent <Renderer>().material.SetTexture("wall", default);
                    matrizCelulas[l, c].paredeNorte.transform.SetParent(Labirinto);
                }

                matrizCelulas[l, c].paredeSul      = Instantiate(Parede, new Vector3((l * escalaGameObj) + (escalaGameObj / 2f), 0.8f, c * escalaGameObj), Quaternion.identity) as GameObject;
                matrizCelulas[l, c].paredeSul.name = "Parede (Sul) " + l + "," + c;
                matrizCelulas[l, c].paredeSul.transform.Rotate(Vector3.up * 90f);
                matrizCelulas[l, c].paredeSul.tag   = "Parede";
                matrizCelulas[l, c].paredeSul.layer = LayerMask.NameToLayer("Parede");
                matrizCelulas[l, c].paredeSul.GetComponent <Renderer>().material.SetColor("_Color", new Vector4(0.05f, 0.05f, 0.05f));
                matrizCelulas[l, c].paredeSul.GetComponent <Renderer>().material.SetTexture("wall", default);
                matrizCelulas[l, c].paredeSul.transform.SetParent(Labirinto);
            }
        }
    }