Exemple #1
0
 private void Form1_Load(object sender, EventArgs e)
 {
     blackPoints    = 2;
     whitePoints    = 2;
     mainBoard      = new Board();
     pieces         = mainBoard.GetPieces();
     turnLabel.Text = "BLACK's TURN";
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 8; x++)
         {
             pieces[x, y].Click += this.Piece_Click;
             this.Controls.Add(pieces[x, y]);
             if ((x == 3 || x == 4) && (y == 3 || y == 4))
             {
                 if (x - y == 0)
                 {
                     pieces[x, y].PieceState = Piece.PIECE_STATE.STATE_BLACK;
                 }
                 else
                 {
                     pieces[x, y].PieceState = Piece.PIECE_STATE.STATE_WHITE;
                 }
             }
         }
     }
 }
Exemple #2
0
 private void newGameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     blackTurn = true;
     foreach (Piece piece in pieces)
     {
         Controls.Remove(piece);
     }
     blackPoints    = 2;
     whitePoints    = 2;
     mainBoard      = new Board();
     pieces         = mainBoard.GetPieces();
     turnLabel.Text = "BLACK's TURN";
     for (int y = 0; y < 8; y++)
     {
         for (int x = 0; x < 8; x++)
         {
             pieces[x, y].Click += this.Piece_Click;
             this.Controls.Add(pieces[x, y]);
             if ((x == 3 || x == 4) && (y == 3 || y == 4))
             {
                 if (x - y == 0)
                 {
                     pieces[x, y].PieceState = Piece.PIECE_STATE.STATE_BLACK;
                 }
                 else
                 {
                     pieces[x, y].PieceState = Piece.PIECE_STATE.STATE_WHITE;
                 }
             }
         }
     }
 }