private void black_player2_Click(object sender, EventArgs e) { this.color_player2_is_empty = true; // the player choos any color. this.player2_color = Color_Type.BLACK; this.black_player2.FlatAppearance.BorderSize = 4; // bold this button // cancel the board if it is this.white_player2.FlatAppearance.BorderSize = 0; this.blue_player2.FlatAppearance.BorderSize = 0; this.red_player2.FlatAppearance.BorderSize = 0; }
public event EventHandler update_data; // this event update field public Manager(General_Piece[,] board_from_form, string player1_name, string player2_name, Color_Type player1_color, Color_Type player2_color) { this._board = board_from_form; this.player1_name = player1_name; this.player1_color = player1_color; this.player2_name = player2_name; this.player2_color = player2_color; this.moves_number = 0; this.is_Player1_turn = true; this.is_Game_Over = false; this.Game_Run(); }
// This function show all pawns -- soldiers in the board. private void Show_pawns(int player, Color_Type color) { int player_pawn_position = 1; // this variable present when to put all pawn, player 1 -> line 1 , player 2-> line 6 if (player == 2) { player_pawn_position = 6; // player 1 is stay 1 and if 2 so to line 6 } switch (color) { case Color_Type.BLACK: // color black for (int i = 0; i < 8; i++) { this._board[i, player_pawn_position].Set_picBox_background(All_pieces.pawn_black); this._board[i, player_pawn_position].SetType(Piece_Type.PAWN); // set the type, pawn } break; case Color_Type.WHITE: // color white for (int i = 0; i < 8; i++) { this._board[i, player_pawn_position].Set_picBox_background(All_pieces.pawn_white); this._board[i, player_pawn_position].SetType(Piece_Type.PAWN); // set the type, pawn } break; case Color_Type.BLUE: // color blue for (int i = 0; i < 8; i++) { this._board[i, player_pawn_position].Set_picBox_background(All_pieces.pawn_blue); this._board[i, player_pawn_position].SetType(Piece_Type.PAWN); // set the type, pawn } break; case Color_Type.RED: // color red for (int i = 0; i < 8; i++) { this._board[i, player_pawn_position].Set_picBox_background(All_pieces.pawn_red); this._board[i, player_pawn_position].SetType(Piece_Type.PAWN); // set the type, pawn } break; } }
public Game_Form(string player1_name, string player2_name, Color_Type player1_color, Color_Type player2_color) { InitializeComponent(); gameTime_timer.Start(); // start timer for Time of game this.player1_name = player1_name; this.player1_color = player1_color; this.player2_name = player2_name; this.player2_color = player2_color; this.Show_Names_on_Form(); // This function show the name of all players on the form this.Create_Matrix_board(); this.game_Manager = new Manager(this._board, player1_name, player2_name, player1_color, player2_color); this.game_Manager.update_data += game_Manager_update_data; }
// This function show other pieces -- rook,knight,bishop,quenn,king in the board. private void Show_Others_Piece(int player, Color_Type color) { int player_pawn_position = 0; // this variable present when to put all pawn, player 1 -> line 1 , player 2-> line 6 if (player == 2) { player_pawn_position = 7; // player 1 is stay 1 and if 2 so to line 6 } switch (color) { case Color_Type.BLACK: // color black // all rooks this._board[0, player_pawn_position].Set_picBox_background(All_pieces.rook_black); this._board[7, player_pawn_position].Set_picBox_background(All_pieces.rook_black); this._board[0, player_pawn_position].SetType(Piece_Type.ROOK); this._board[7, player_pawn_position].SetType(Piece_Type.ROOK); // all knights this._board[1, player_pawn_position].Set_picBox_background(All_pieces.knight_black); this._board[6, player_pawn_position].Set_picBox_background(All_pieces.knight_black); this._board[1, player_pawn_position].SetType(Piece_Type.KNIGHT); this._board[6, player_pawn_position].SetType(Piece_Type.KNIGHT); // all bishops this._board[2, player_pawn_position].Set_picBox_background(All_pieces.bishop_black); this._board[5, player_pawn_position].Set_picBox_background(All_pieces.bishop_black); this._board[2, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[5, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[3, player_pawn_position].Set_picBox_background(All_pieces.queen_black); this._board[3, player_pawn_position].SetType(Piece_Type.QUEEN); this._board[4, player_pawn_position].Set_picBox_background(All_pieces.king_black); this._board[4, player_pawn_position].SetType(Piece_Type.KING); break; case Color_Type.WHITE: // color white // all rooks this._board[0, player_pawn_position].Set_picBox_background(All_pieces.rook_white); this._board[7, player_pawn_position].Set_picBox_background(All_pieces.rook_white); this._board[0, player_pawn_position].SetType(Piece_Type.ROOK); this._board[7, player_pawn_position].SetType(Piece_Type.ROOK); // all knights this._board[1, player_pawn_position].Set_picBox_background(All_pieces.knight_white); this._board[6, player_pawn_position].Set_picBox_background(All_pieces.knight_white); this._board[1, player_pawn_position].SetType(Piece_Type.KNIGHT); this._board[6, player_pawn_position].SetType(Piece_Type.KNIGHT); // all bishops this._board[2, player_pawn_position].Set_picBox_background(All_pieces.bishop_white); this._board[5, player_pawn_position].Set_picBox_background(All_pieces.bishop_white); this._board[2, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[5, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[3, player_pawn_position].Set_picBox_background(All_pieces.queen_white); this._board[3, player_pawn_position].SetType(Piece_Type.QUEEN); this._board[4, player_pawn_position].Set_picBox_background(All_pieces.king_white); this._board[4, player_pawn_position].SetType(Piece_Type.KING); break; case Color_Type.BLUE: // color blue // all rooks this._board[0, player_pawn_position].Set_picBox_background(All_pieces.rook_blue); this._board[7, player_pawn_position].Set_picBox_background(All_pieces.rook_blue); this._board[0, player_pawn_position].SetType(Piece_Type.ROOK); this._board[7, player_pawn_position].SetType(Piece_Type.ROOK); // all knights this._board[1, player_pawn_position].Set_picBox_background(All_pieces.knight_blue); this._board[6, player_pawn_position].Set_picBox_background(All_pieces.knight_blue); this._board[1, player_pawn_position].SetType(Piece_Type.KNIGHT); this._board[6, player_pawn_position].SetType(Piece_Type.KNIGHT); // all bishops this._board[2, player_pawn_position].Set_picBox_background(All_pieces.bishop_blue); this._board[5, player_pawn_position].Set_picBox_background(All_pieces.bishop_blue); this._board[2, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[5, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[3, player_pawn_position].Set_picBox_background(All_pieces.queen_blue); this._board[3, player_pawn_position].SetType(Piece_Type.QUEEN); this._board[4, player_pawn_position].Set_picBox_background(All_pieces.king_blue); this._board[4, player_pawn_position].SetType(Piece_Type.KING); break; case Color_Type.RED: // color red // all rooks this._board[0, player_pawn_position].Set_picBox_background(All_pieces.rook_red); this._board[7, player_pawn_position].Set_picBox_background(All_pieces.rook_red); this._board[0, player_pawn_position].SetType(Piece_Type.ROOK); this._board[7, player_pawn_position].SetType(Piece_Type.ROOK); // all knights this._board[1, player_pawn_position].Set_picBox_background(All_pieces.knight_red); this._board[6, player_pawn_position].Set_picBox_background(All_pieces.knight_red); this._board[1, player_pawn_position].SetType(Piece_Type.KNIGHT); this._board[6, player_pawn_position].SetType(Piece_Type.KNIGHT); // all bishops this._board[2, player_pawn_position].Set_picBox_background(All_pieces.bishop_red); this._board[5, player_pawn_position].Set_picBox_background(All_pieces.bishop_red); this._board[2, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[5, player_pawn_position].SetType(Piece_Type.BISHOP); this._board[3, player_pawn_position].Set_picBox_background(All_pieces.queen_red); this._board[3, player_pawn_position].SetType(Piece_Type.QUEEN); this._board[4, player_pawn_position].Set_picBox_background(All_pieces.king_red); this._board[4, player_pawn_position].SetType(Piece_Type.KING); break; } }