示例#1
0
        public static int ChecarTipoAreaAdjacente(Celula celula, string tipoChecado, int area)
        {
            int contador = 0;

            for (int i = celula.coordCelulaDun.x - area; i <= celula.coordCelulaDun.x + area; i++)
            {
                for (int j = celula.coordCelulaDun.y - area; j <= celula.coordCelulaDun.y + area; j++)
                {
                    if (i >= 0 && j >= 0 && i < celula.dungeonPai.tamanhoDungeon.x && j < celula.dungeonPai.tamanhoDungeon.y)
                    {
                        if (celula.dungeonPai.dungeon[i, j].tipoCelula == tipoChecado)
                        {
                            contador++;
                        }
                    }
                }
            }

            return(contador);
        }
示例#2
0
        public static int checarTipoAdjacentes(Celula celula, string tipoChecado, int area)
        {
            int contador = 0;

            for (int i = 1; i <= area; i++)
            {
                if (celula.coordCelulaDun.x - i >= 0)
                {
                    if (celula.dungeonPai.dungeon[celula.coordCelulaDun.x - i, celula.coordCelulaDun.y].tipoCelula == tipoChecado)
                    {
                        contador++;
                    }
                }
                if (celula.coordCelulaDun.x + i < celula.dungeonPai.tamanhoDungeon.x)
                {
                    if (celula.dungeonPai.dungeon[celula.coordCelulaDun.x + i, celula.coordCelulaDun.y].tipoCelula == tipoChecado)
                    {
                        contador++;
                    }
                }
                if (celula.coordCelulaDun.y + i < celula.dungeonPai.tamanhoDungeon.y)
                {
                    if (celula.dungeonPai.dungeon[celula.coordCelulaDun.x, celula.coordCelulaDun.y + i].tipoCelula == tipoChecado)
                    {
                        contador++;
                    }
                }
                if (celula.coordCelulaDun.y - i >= 0)
                {
                    if (celula.dungeonPai.dungeon[celula.coordCelulaDun.x, celula.coordCelulaDun.y - i].tipoCelula == tipoChecado)
                    {
                        contador++;
                    }
                }
            }

            return(contador);
        }
示例#3
0
 public void pegarAdjacentes(Celula celula)
 {
     celula.adjesq   = null;
     celula.adjdir   = null;
     celula.adjcima  = null;
     celula.adjbaixo = null;
     if (celula.coordCelulaDun.x - 1 >= 0)
     {
         celula.adjesq = celula.dungeonPai.dungeon[celula.coordCelulaDun.x - 1, celula.coordCelulaDun.y];
     }
     if (celula.coordCelulaDun.x + 1 <= celula.dungeonPai.tamanhoDungeon.x - 1)
     {
         celula.adjdir = celula.dungeonPai.dungeon[celula.coordCelulaDun.x + 1, celula.coordCelulaDun.y];
     }
     if (celula.coordCelulaDun.y - 1 >= 0)
     {
         celula.adjcima = celula.dungeonPai.dungeon[celula.coordCelulaDun.x, celula.coordCelulaDun.y - 1];
     }
     if (celula.coordCelulaDun.y + 1 <= celula.dungeonPai.tamanhoDungeon.y - 1)
     {
         celula.adjbaixo = celula.dungeonPai.dungeon[celula.coordCelulaDun.x, celula.coordCelulaDun.y + 1];
     }
 }
示例#4
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;
        }