Beispiel #1
0
 public Game()
 {
     rc[0]  = new Horse(0, 1, "傌", "red");
     rc[1]  = new Elephant(0, 2, "相", "red");
     rc[2]  = new Advisor(0, 3, "仕", "red");
     rc[3]  = new General(0, 4, "帅", "red");
     rc[4]  = new Advisor(0, 5, "仕", "red");
     rc[5]  = new Elephant(0, 6, "相", "red");
     rc[6]  = new Horse(0, 7, "傌", "red");
     rc[7]  = new Rook(0, 8, "俥", "red");
     rc[8]  = new Cannon(2, 1, "炮", "red");
     rc[9]  = new Cannon(2, 7, "炮", "red");
     rc[10] = new Soilder(3, 0, "兵", "red");
     rc[11] = new Soilder(3, 2, "兵", "red");
     rc[12] = new Soilder(3, 4, "兵", "red");
     rc[13] = new Soilder(3, 6, "兵", "red");
     rc[14] = new Soilder(3, 8, "兵", "red");
     rc[15] = new Rook(0, 0, "俥", "red");
     bc[0]  = new Horse(9, 1, "馬", "black");
     bc[1]  = new Elephant(9, 2, "象", "black");
     bc[2]  = new Advisor(9, 3, "士", "black");
     bc[3]  = new General(9, 4, "将", "black");
     bc[4]  = new Advisor(9, 5, "士", "black");
     bc[5]  = new Elephant(9, 6, "象", "black");
     bc[6]  = new Horse(9, 7, "馬", "black");
     bc[7]  = new Rook(9, 8, "車", "black");
     bc[8]  = new Cannon(7, 1, "砲", "black");
     bc[9]  = new Cannon(7, 7, "砲", "black");
     bc[10] = new Soilder(6, 0, "卒", "black");
     bc[11] = new Soilder(6, 2, "卒", "black");
     bc[12] = new Soilder(6, 4, "卒", "black");
     bc[13] = new Soilder(6, 6, "卒", "black");
     bc[14] = new Soilder(6, 8, "卒", "black");
     bc[15] = new Rook(9, 0, "車", "black");
     refresh(board, rc, bc);
 }
Beispiel #2
0
        private void PlacePawns()
        {
            gameState = GameState.PLAYING;

            blackGeneral = new General(PlayerSide.BLACK);
            redGeneral   = new General(PlayerSide.RED);

            colBlackGeneral = 4;
            rowBlackGeneral = 0;

            colRedGeneral = 4;
            rowRedGeneral = 9;

            blackGeneralChecked = false;
            redGeneralChecked   = false;

            threateningPawn    = null;
            rowThreateningPawn = -1;
            colThreateningPawn = -1;

            selectedPawn = Rectangle.Empty;
            selectedCol  = -1;
            selectedRow  = -1;
            selectedPawnPossibleMovements = null;

            // Black side.
            gameBoardPositions[0, 0] = new Rook(PlayerSide.BLACK);
            gameBoardPositions[0, 1] = new Knight(PlayerSide.BLACK);
            gameBoardPositions[0, 2] = new Elephant(PlayerSide.BLACK);
            gameBoardPositions[0, 3] = new Advisor(PlayerSide.BLACK);
            gameBoardPositions[0, 4] = blackGeneral;
            gameBoardPositions[0, 5] = new Advisor(PlayerSide.BLACK);
            gameBoardPositions[0, 6] = new Elephant(PlayerSide.BLACK);
            gameBoardPositions[0, 7] = new Knight(PlayerSide.BLACK);
            gameBoardPositions[0, 8] = new Rook(PlayerSide.BLACK);

            gameBoardPositions[2, 1] = new Cannon(PlayerSide.BLACK);
            gameBoardPositions[2, 7] = new Cannon(PlayerSide.BLACK);

            gameBoardPositions[3, 0] = new Soldier(PlayerSide.BLACK);
            gameBoardPositions[3, 2] = new Soldier(PlayerSide.BLACK);
            gameBoardPositions[3, 4] = new Soldier(PlayerSide.BLACK);
            gameBoardPositions[3, 6] = new Soldier(PlayerSide.BLACK);
            gameBoardPositions[3, 8] = new Soldier(PlayerSide.BLACK);

            // Red side.
            gameBoardPositions[9, 0] = new Rook(PlayerSide.RED);
            gameBoardPositions[9, 1] = new Knight(PlayerSide.RED);
            gameBoardPositions[9, 2] = new Elephant(PlayerSide.RED);
            gameBoardPositions[9, 3] = new Advisor(PlayerSide.RED);
            gameBoardPositions[9, 4] = redGeneral;
            gameBoardPositions[9, 5] = new Advisor(PlayerSide.RED);
            gameBoardPositions[9, 6] = new Elephant(PlayerSide.RED);
            gameBoardPositions[9, 7] = new Knight(PlayerSide.RED);
            gameBoardPositions[9, 8] = new Rook(PlayerSide.RED);

            gameBoardPositions[7, 1] = new Cannon(PlayerSide.RED);
            gameBoardPositions[7, 7] = new Cannon(PlayerSide.RED);

            gameBoardPositions[6, 0] = new Soldier(PlayerSide.RED);
            gameBoardPositions[6, 2] = new Soldier(PlayerSide.RED);
            gameBoardPositions[6, 4] = new Soldier(PlayerSide.RED);
            gameBoardPositions[6, 6] = new Soldier(PlayerSide.RED);
            gameBoardPositions[6, 8] = new Soldier(PlayerSide.RED);

            // Fill null cells with empty pawns.
            for (int row = 0; row < 10; row++)
            {
                for (int col = 0; col < 9; col++)
                {
                    if (gameBoardPositions[row, col] == null)
                    {
                        gameBoardPositions[row, col] = new EmptyPawn();
                    }
                }
            }
        }