Beispiel #1
0
        public void inicializarTablero()
        {
            int i, j;

            //Piezaz Negras Arriba
            tablero[0, 0] = new Casilla("rook", false);
            tablero[1, 0] = new Casilla("knight", false);
            tablero[2, 0] = new Casilla("bishop", false);
            tablero[3, 0] = new Casilla("queen", false);
            tablero[4, 0] = new Casilla("king", false);
            tablero[5, 0] = new Casilla("bishop", false);
            tablero[6, 0] = new Casilla("knight", false);
            tablero[7, 0] = new Casilla("rook", false);
            for (i = 0; i < 8; i++)
            {
                tablero[i, 1] = new Casilla("pawn", false);
            }
            for (i = 0; i < 8; i++)
            {
                for (j = 2; j < 6; j++)
                {
                    tablero[i, j] = new Casilla();
                }
            }
            //tablero Blancas Abajo
            for (i = 0; i < 8; i++)
            {
                tablero[i, 6] = new Casilla("pawn", true);
            }
            tablero[0, 7] = new Casilla("rook", true);
            tablero[1, 7] = new Casilla("knight", true);
            tablero[2, 7] = new Casilla("bishop", true);
            tablero[3, 7] = new Casilla("queen", true);
            tablero[4, 7] = new Casilla("king", true);
            tablero[5, 7] = new Casilla("bishop", true);
            tablero[6, 7] = new Casilla("knight", true);
            tablero[7, 7] = new Casilla("rook", true);

            for (i = 0; i < 8; i++)//Dibujo Tablero
            {
                for (j = 0; j < 8; j++)
                {
                    tablero[i, j].btn          = new Button();
                    tablero[i, j].btn.Size     = new System.Drawing.Size(70, 70);
                    tablero[i, j].btn.Location = new System.Drawing.Point(i * 69, j * 69);
                    tablero[i, j].btn.FlatAppearance.BorderSize = 0;
                    mosaico(i, j, "");
                    colocaPieza(i, j);
                    tablero[i, j].btn.Click += new EventHandler(onButtonClick);
                    this.Controls.Add(tablero[i, j].btn);
                }
            }
        }
Beispiel #2
0
        /** @brief Permite  Dibujar el tablero
         *
         * Se dibujan tres capas del tablero, en la primera capa se dibuja el tablero con las fichas
         * en la segunda capa se dibuja otro tablero mas transparente encima, en el que se dibuja en que casilla
         * esta el mouse parado. La tercera capa colorea de verde la posicion de las casillas que tienen que comer
         * una ficha si hay alguna.
         *
         * @param[in]  spritebatch             Es el objeto que nos ayuda a dibujar imagenes en la pantalla
         * @param[in]  _currentMousePosition   Es la posicion en la que se encuentra el mouse.
         * @param[in]  _dragAndDropController  Es el objeto que contiene la lista de fichas y controla el dragAndDrop
         *
         * @return     no retorna nada
         *
         */
        public void draw(SpriteBatch spritebatch, Vector2 _currentMousePosition, GameTime gameTime)
        {
            float opacity;
            Color colorToUse = Color.White;

            // Dimensiones de las casillas 80px x 80px
            const int _tileSize = 80;

            //the square to draw (local variable to avoid creating a new variable per square)
            Rectangle squareToDrawPosition = new Rectangle();


            // Se recorre el arreglo de casillas
            for (int y = 0; y < casillas.GetLength(0); y++)
            {
                for (int x = 0; x < casillas.GetLength(1); x++)
                {
                    //figure out where to draw the square
                    squareToDrawPosition = new Rectangle((int)(x * _tileSize + posicion.X), (int)(y * _tileSize + posicion.Y), _tileSize, _tileSize);

                    Vector2 squarePosition = new Vector2(x * _tileSize + posicion.X, y * _tileSize + posicion.Y);
                    //if we add the x and y value of the tile
                    //and it is even, we make it one third opaque
                    if ((x + y) % 2 == 0)
                    {
                        opacity = .33f;
                    }
                    else
                    {
                        //otherwise it is one tenth opaque
                        opacity = .1f;
                    }
                    //make the square the mouse is over red
                    if (IsMouseOnTile(x, y, _currentMousePosition))
                    {
                        colorToUse = Color.Red;
                        opacity    = .5f;
                    }
                    else
                    {
                        colorToUse = Color.White;
                    }


                    Casilla c1 = casillas[x, y];
                    spritebatch.Draw(c1.Img, c1.Posicion, null, Color.WhiteSmoke);
                    //draw the white square at the given position, offset by the x- and y-offset, in the opacity desired
                    spritebatch.Draw(_whiteSquare, squareToDrawPosition, colorToUse * opacity);
                }
            }
        }
Beispiel #3
0
        void inicializarTablero()
        {
            DateTime ti, tf;
            int      i, j;
            Tamaño   dtam = new Tamaño(this);

            dtam.ShowDialog();
            tam = n * n;
            ti  = DateTime.Now;
            caballos(0);
            tf = DateTime.Now;
            TimeSpan tt = new TimeSpan(tf.Ticks - ti.Ticks);

            MessageBox.Show("Tiempo" + tt.ToString());
            this.Size    = new System.Drawing.Size(n * 70 + 100, n * 70 + 25);
            lbSoluciones = new System.Windows.Forms.ListBox();
            lbSoluciones.FormattingEnabled = true;
            lbSoluciones.Location          = new System.Drawing.Point(n * 69, 0);
            lbSoluciones.Size        = new System.Drawing.Size(100, n * 70);
            lbSoluciones.TabIndex    = 0;
            lbSoluciones.MouseClick += new System.Windows.Forms.MouseEventHandler(this.Soluciones_MouseClick);
            this.Controls.Add(lbSoluciones);
            nSol = 0;
            i    = 1;
            foreach (Solucion s in soluciones)
            {
                if (s.nK == max)
                {
                    lbSoluciones.Items.Add("Solucion: " + i.ToString());
                    i++;
                }
                else
                {
                    nSol++;
                }
            }
            for (i = 0; i < n; i++)//Dibujo Tablero
            {
                for (j = 0; j < n; j++)
                {
                    tablero[i, j]              = new Casilla();
                    tablero[i, j].btn          = new Button();
                    tablero[i, j].btn.Size     = new System.Drawing.Size(70, 70);
                    tablero[i, j].btn.Location = new System.Drawing.Point(i * 69, j * 69);
                    tablero[i, j].btn.FlatAppearance.BorderSize = 0;
                    mosaico(i, j, "", false);
                    tablero[i, j].btn.Click += new EventHandler(onButtonClick);
                    this.Controls.Add(tablero[i, j].btn);
                }
            }
        }
Beispiel #4
0
 protected void SetupDraggableItems()
 {
     _dragDropController.Clear();
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             Casilla c1 = board.Casillas[j, i];
             // Si hay una ficha en la casilla insertala en el dragAndDropController
             if (c1.FichaContenida != null)
             {
                 Ficha item = c1.FichaContenida;
                 _dragDropController.Add(item);
             }
         }
     }
 }
Beispiel #5
0
        public void inicializarTablero()
        {
            int i, j;

            for (i = 0; i < 8; i++)//Dibujo Tablero
            {
                for (j = 0; j < 8; j++)
                {
                    tablero[i, j]              = new Casilla();
                    tablero[i, j].btn          = new Button();
                    tablero[i, j].btn.Size     = new System.Drawing.Size(70, 70);
                    tablero[i, j].btn.Location = new System.Drawing.Point(i * 69, j * 69);
                    tablero[i, j].btn.FlatAppearance.BorderSize = 0;
                    mosaico(i, j, "");
                    tablero[i, j].btn.Click += new EventHandler(onButtonClick);
                    this.Controls.Add(tablero[i, j].btn);
                }
            }
            comenzarNuevo();
        }
Beispiel #6
0
        /** Constructores*/
        public Tablero(ContentManager content)
        {
            //Se inicializa la posicion del tablero
            posicion = new Vector2(70, 20);

            //Se le asignan las posiciones a cada casilla
            for (int i = 0; i < casillas.GetLength(0); i++)
            {
                for (int j = 0; j < casillas.GetLength(1); j++)
                {
                    int posicionXPantalla = 70 + (i) * 80;
                    int posicionYPantalla = 20 + (j) * 80;
                    casillas[i, j] = new Casilla()
                    {
                        Posicion = new Vector2(posicionXPantalla, posicionYPantalla)
                    };
                }
            }
            //Se le asignan los colores a las casillas
            setColorCasillas(content);
        }