示例#1
0
        /*******************************************************************/
        // KING LOGIC                                                      */
        /*******************************************************************/
        protected void CheckKing(int y, int x, char brickChar, bool brickChange)
        {
            // Used to set what direction the brick should go on the y axis
            CheckBrickChange(brickChange);

            if (ChessMap.CheckMapArray(x, y, brickChar))
            {
                // Set marker where the queen brick can move on y- axis
                for (int i = -1; i < 2; i++)
                {
                    for (int j = -1; j < 2; j++)
                    {
                        // Set marker where the queen can kill
                        if ((CheckCellEnemy(x + (-j * brickDire), y + (-i * brickDire), brickChange)))
                        {
                            ChessMap.SetMoveArray(x + (-j * brickDire), y + (-i * brickDire), '#');
                        }

                        // Set marker where the queen can move
                        if (ChessMap.CheckMapArray(x + (-j * brickDire), y + (-i * brickDire), ' '))
                        {
                            ChessMap.SetMoveArray(x + (-j * brickDire), y + (-i * brickDire), '*');
                            ChessMap.SetMapArray(x + (-j * brickDire), y + (-i * brickDire), '*');
                        }
                    }
                }
                // Used to set brick variables
                SetBrickVariables(brickChar, x, y);
            }
        }
示例#2
0
 // Used to check eneme cell
 private bool CheckCellEnemy(int x, int y, bool brickChange)
 {
     // Check enemys for white brick
     if (brickChange == true)
     {
         for (int i = 97; i < 103; i++)
         {
             if (ChessMap.CheckMapArray(x, y, (char)i))
             {
                 return(true);
             }
         }
     }
     // Check enemys for black brick
     else
     {
         for (int i = 65; i < 71; i++)
         {
             if (ChessMap.CheckMapArray(x, y, (char)i))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#3
0
        protected void CheckWin()
        {
            bool kingWhite = false;
            bool kingBlack = false;

            for (int y = 0; y < 8; y++)
            {
                for (int x = 0; x < 8; x++)
                {
                    if (ChessMap.CheckMapArray(x, y, 'F'))
                    {
                        kingWhite = true;
                    }
                    if (ChessMap.CheckMapArray(x, y, 'f'))
                    {
                        kingBlack = true;
                    }
                }
            }
            if (kingWhite == false)
            {
                Win("Black wins!");
            }
            if (kingBlack == false)
            {
                Win("White wins!");
            }
        }
示例#4
0
        void ImportImage(int x, int y, char character, string path)
        {
            if (ChessMap.CheckMapArray(x, y, character))
            {
                BitmapImage btm = new BitmapImage(new Uri(path, UriKind.Relative));
                btm.UriSource = new Uri(path, UriKind.Relative);

                img[y, x].Source = btm;

                mapButton[y, x].Content = img[y, x];
            }
        }
示例#5
0
        /*******************************************************************/
        // BISHOP LOGIC                                                    */
        /*******************************************************************/
        protected void CheckBishop(int y, int x, char brickChar, bool brickChange)
        {
            // Used to set what direction the brick should go on the y axis
            CheckBrickChange(brickChange);

            if (ChessMap.CheckMapArray(x, y, brickChar))
            {
                // Set marker where the bishop brick can move and kill
                CheckMovement(8, x, y, brickDire, brickDire, brickChange, true);   // xy-    axis
                CheckMovement(8, x, y, -brickDire, -brickDire, brickChange, true); // xy+    axis
                CheckMovement(8, x, y, brickDire, -brickDire, brickChange, true);  // x-, y+ axis
                CheckMovement(8, x, y, -brickDire, brickDire, brickChange, true);  // x+, y- axis

                // Used to set brick variables
                SetBrickVariables(brickChar, x, y);
            }
        }
示例#6
0
        /*******************************************************************/
        // PAWN LOGIC                                                      */
        /*******************************************************************/
        protected void CheckPawn(int y, int x, char brickChar, bool brickChange)
        {
            // Used to set what direction the brick should go on the y axis
            CheckBrickChange(brickChange);

            if (ChessMap.CheckMapArray(x, y, brickChar))
            {
                // Start position with pawn allows to move 1 step more forward
                int cellMove = 1;
                if ((y == 6) && (brickChange == true))
                {
                    cellMove = 2;
                }
                if ((y == 1) && (brickChange == false))
                {
                    cellMove = 2;
                }

                // Set marker where the pawn brick can move on the y- axis
                for (int i = 1; i < 1 + cellMove; i++)
                {
                    if (ChessMap.CheckMapArray(x, y + (-i * brickDire), ' '))
                    {
                        ChessMap.SetMoveArray(x, y + (-i * brickDire), '*');
                        ChessMap.SetMapArray(x, y + (-i * brickDire), '*');
                    }
                    else
                    {
                        break;
                    }
                }
                // Set stafe marker where the pawn brick can kill
                for (int j = -1; j < 2; j++)
                {
                    if ((CheckCellEnemy(x + j, y + (-1 * brickDire), brickChange)) && (j != 0))
                    {
                        ChessMap.SetMoveArray(x + j, y + (-1 * brickDire), '#');
                    }
                }

                // Used to set brick variables
                SetBrickVariables(brickChar, x, y);
            }
        }
示例#7
0
 // Used to check where the brick is allowed to move
 private void CheckMovement(int loopLength, int x, int y, int xDire, int yDire, bool brickChange, bool brickBlock)
 {
     for (int i = 1; i < loopLength; i++)
     {
         if ((CheckCellEnemy(x + (-i * xDire), y + (-i * yDire), brickChange)))
         {
             ChessMap.SetMoveArray(x + (-i * xDire), y + (-i * yDire), '#');
         }
         if (ChessMap.CheckMapArray(x + (-i * xDire), y + (-i * yDire), ' '))
         {
             ChessMap.SetMoveArray(x + (-i * xDire), y + (-i * yDire), '*');
             ChessMap.SetMapArray(x + (-i * xDire), y + (-i * yDire), '*');
         }
         else if (brickBlock == true)
         {
             return;
         }
     }
 }
示例#8
0
        /*******************************************************************/
        // KNIGHT LOGIC                                                    */
        /*******************************************************************/
        protected void CheckKnight(int y, int x, char brickChar, bool brickChange)
        {
            // Used to set what direction the brick should go on the y axis
            CheckBrickChange(brickChange);

            if (ChessMap.CheckMapArray(x, y, brickChar))
            {
                // Set marker where the horse brick can move and kill
                CheckMovement(2, x, y, brickDire, brickDire * 2, brickChange, false);
                CheckMovement(2, x, y, -brickDire, brickDire * 2, brickChange, false);
                CheckMovement(2, x, y, brickDire, -brickDire * 2, brickChange, false);
                CheckMovement(2, x, y, -brickDire, -brickDire * 2, brickChange, false);
                CheckMovement(2, x, y, brickDire * 2, brickDire, brickChange, false);
                CheckMovement(2, x, y, brickDire * 2, -brickDire, brickChange, false);
                CheckMovement(2, x, y, -brickDire * 2, brickDire, brickChange, false);
                CheckMovement(2, x, y, -brickDire * 2, -brickDire, brickChange, false);

                // Used to set brick variables
                SetBrickVariables(brickChar, x, y);
            }
        }