Exemple #1
0
        public static Ficha GeneratePiece()
        {
            Ficha ficha = new Ficha();

            ficha.Color = Ficha.GetRandomColorFicha();
            return(ficha);
        }
Exemple #2
0
        private void checkCelda(int rowIndex, int colIndex, Ficha 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 != null && this.Celdas[rowIndex, colIndex].Ficha.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);
            }
        }
Exemple #3
0
        public IList <Celda> NuevoMovimiento(int rowIndex, int colIndex, Ficha 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);
            }
        }
Exemple #4
0
        public static Tablero GenerateBoardFromString(string tableroStr)
        {
            string[] lineas = tableroStr.Split('\n');
            Tablero  t      = 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 == 'X')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex);
                    }
                    if (ficharChar == '1')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Rojo));
                    }
                    if (ficharChar == '2')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Azul));
                    }
                    if (ficharChar == '3')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Verde));
                    }
                    if (ficharChar == '4')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(ColorFicha.Amarillo));
                    }
                    if (ficharChar == 'R')
                    {
                        t.Celdas[filaIndex, colIndex] = new Celda(filaIndex, colIndex, new Ficha(Ficha.GetRandomColorFicha()));
                    }

                    colIndex++;
                }

                filaIndex++;
            }

            return(t);
        }
Exemple #5
0
 public Celda(int rowIndex, int colIndex, Ficha ficha) : this(rowIndex, colIndex)
 {
     this.Ficha = ficha;
 }