Beispiel #1
0
        public static FichaRGB GeneratePiece()
        {
            FichaRGB ficha = new FichaRGB();

            ficha.Color = FichaRGB.GetRandomColorFicha();
            return(ficha);
        }
Beispiel #2
0
        private void checkCelda(int rowIndex, int colIndex, FichaRGB fichaNueva, IList <Celda> celdasARomper)
        {
            if (yaSeChequeoCelda(rowIndex, colIndex))
            {
                return;
            }

            if (rowIndex < 0 || colIndex < 0 || rowIndex > this.Size - 1 || colIndex > this.Size - 1)
            {
                return;
            }

            if (this.Celdas[rowIndex, colIndex].Ficha is FichaBrick)
            {
                this.celdasYaChequeadas.Add(this.Celdas[rowIndex, colIndex]);
                return;
            }
            if (this.Celdas[rowIndex, colIndex].Ficha != null && (this.Celdas[rowIndex, colIndex].Ficha as FichaRGB).Color == fichaNueva.Color)
            {
                celdasARomper.Add(this.Celdas[rowIndex, colIndex]);
                this.celdasYaChequeadas.Add(this.Celdas[rowIndex, colIndex]);
                checkCelda(rowIndex - 1, colIndex, fichaNueva, celdasARomper);
                checkCelda(rowIndex + 1, colIndex, fichaNueva, celdasARomper);
                checkCelda(rowIndex, colIndex - 1, fichaNueva, celdasARomper);
                checkCelda(rowIndex, colIndex + 1, fichaNueva, celdasARomper);
            }
        }
Beispiel #3
0
        public IList <Celda> NuevoMovimiento(int rowIndex, int colIndex, FichaRGB fichaNueva)
        {
            celdasYaChequeadas.Clear();
            IList <Celda> celdasARomper = new List <Celda>();

            this.Celdas[rowIndex, colIndex].Ficha = fichaNueva;
            celdasARomper.Add(this.Celdas[rowIndex, colIndex]);
            celdasYaChequeadas.Add(this.Celdas[rowIndex, colIndex]);


            checkCelda(rowIndex, colIndex - 1, fichaNueva, celdasARomper);
            checkCelda(rowIndex, colIndex + 1, fichaNueva, celdasARomper);
            checkCelda(rowIndex - 1, colIndex, fichaNueva, celdasARomper);
            checkCelda(rowIndex + 1, colIndex, fichaNueva, celdasARomper);

            if (celdasARomper.Count >= 3)
            {
                return(celdasARomper);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        public static Tablero GenerateBoardFromString(string tableroStr, int levelNumber)
        {
            string[] lineas  = tableroStr.Split('\n');
            Tablero  tablero = Tablero.GenerateBoard(lineas.Length);

            int filaIndex = 0;

            foreach (string linea in lineas)
            {
                string lineaLimpia = linea.Trim().ToUpper();
                int    colIndex    = 0;
                foreach (char ficharChar in lineaLimpia)
                {
                    if (ficharChar == '-')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex);
                    }
                    if (ficharChar == '1')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaRGB(ColorFicha.Rojo));
                    }
                    if (ficharChar == '2')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaRGB(ColorFicha.Azul));
                    }
                    if (ficharChar == '3')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaRGB(ColorFicha.Verde));
                    }
                    if (ficharChar == '4')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaRGB(ColorFicha.Amarillo));
                    }
                    if (ficharChar == 'R')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaRGB(FichaRGB.GetRandomColorFicha(levelNumber + 2)));
                    }
                    if (ficharChar == 'B')
                    {
                        tablero.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new FichaBrick());
                    }

                    colIndex++;
                }

                filaIndex++;
            }

            return(tablero);
        }