Пример #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
        /*******************************************************************/
        // 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);
            }
        }
Пример #3
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;
         }
     }
 }
Пример #4
0
        // Used to move the brick
        protected void MoveBrick(int y, int x)
        {
            if ((y != yLast) || (x != xLast))
            {
                if ((ChessMap.CheckMoveArray(x, y, '*')) || (ChessMap.CheckMoveArray(x, y, '#')))
                {
                    // Pawn rule when touching the edge of the map
                    if ((y == 0) && (brickStore == 'A'))
                    {
                        brickStore = 'E';
                    }
                    if ((y == 7) && (brickStore == 'a'))
                    {
                        brickStore = 'e';
                    }

                    int brickCounter = 0;
                    if (ChessMap.CheckMoveArray(x, y, '#'))
                    {
                        brickCounter = 1;
                        if (ChessMap.enableSound == true)
                        {
                            snd_click02.Play();
                        }
                    }
                    else if (ChessMap.enableSound == true)
                    {
                        snd_click01.Play();
                    }

                    ChessMap.SetMapArray(x, y, brickStore);
                    ChessMap.SetMoveArray(x, y, ' ');
                    ChessMap.SetMapArray(xLast, yLast, ' ');
                    brickStore = '!';

                    // Changes the brick team
                    TeamChange(brickCounter);
                }
                ChessMap.brickSelected = false;
            }
        }
Пример #5
0
 // Used clear all brick markers
 protected void ClearBrickMarker()
 {
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 8; x++)
         {
             if (ChessMap.brickSelected == false)
             {
                 if (ChessMap.CheckMoveArray(x, y, '*'))
                 {
                     ChessMap.SetMoveArray(x, y, ' ');
                     ChessMap.SetMapArray(x, y, ' ');
                 }
                 if (ChessMap.CheckMoveArray(x, y, '#'))
                 {
                     ChessMap.SetMoveArray(x, y, ' ');
                 }
             }
         }
     }
 }