private void START_Click_1(object sender, EventArgs e) { if (WhitePieces.Checked == true) { panel1.Controls.Clear(); STARTpanel.Controls.Clear(); Player = (MYCOLOR)(MYCOLOR.WHITE); PlayerTurnBox.BackColor = Color.Black; PlayerTurnBox.ForeColor = Color.White; PlayerTurnBox.Text = "Player White's Turn"; } else if (BlackPieces.Checked == true) { panel1.Controls.Clear(); STARTpanel.Controls.Clear(); Player = (MYCOLOR)MYCOLOR.BLACK; PlayerTurnBox.BackColor = Color.White; PlayerTurnBox.ForeColor = Color.Black; PlayerTurnBox.Text = "Player Black's Turn"; } else { MessageBox.Show("Please Select A Piece Color"); return; } INIT(); }
public Cell(int r, int c, MYCOLOR C, Piece P, int W, int H, int D) { ri = r; ci = c; clo = C; aP = P; this.Width = W / D - 9; this.Height = H / D - 17; if (C == MYCOLOR.BLACK) { this.BackColor = Color.Gray; } if (aP != null) { aP.Draw(this); } }
void TurnChange() { if (Player == MYCOLOR.WHITE) { Player = MYCOLOR.BLACK; PlayerTurnBox.BackColor = Color.White; PlayerTurnBox.ForeColor = Color.Black; PlayerTurnBox.Text = "Player Black's Turn"; } else { Player = MYCOLOR.WHITE; PlayerTurnBox.BackColor = Color.Black; PlayerTurnBox.ForeColor = Color.White; PlayerTurnBox.Text = "Player White's Turn"; } }
public King(MYCOLOR c, string n) : base(c, n) { }
public Bishop(MYCOLOR c, string n) : base(c, n) { }
public Horse(MYCOLOR c, string n) : base(c, n) { }
void INIT() { for (int r = 0; r < Dimension; r++) { for (int c = 0; c < Dimension; c++) { if (r == 1) { Ps[r, c] = new Pawn(MYCOLOR.BLACK, "Black_Pawn.png"); } else if (r == 6) { Ps[r, c] = new Pawn(MYCOLOR.WHITE, "White_Pawn.png"); } else if (r == 0 && (c == 0 || c == 7)) { Ps[r, c] = new Rook(MYCOLOR.BLACK, "Black_Rook.png"); } else if (r == 7 && (c == 0 || c == 7)) { Ps[r, c] = new Rook(MYCOLOR.WHITE, "White_Rook.png"); } else if (r == 0 && (c == 1 || c == 6)) { Ps[r, c] = new Horse(MYCOLOR.BLACK, "Black_Knight.png"); } else if (r == 7 && (c == 1 || c == 6)) { Ps[r, c] = new Horse(MYCOLOR.WHITE, "White_Knight.png"); } else if (r == 0 && (c == 2 || c == 5)) { Ps[r, c] = new Bishop(MYCOLOR.BLACK, "Black_Bishop.png"); } else if (r == 7 && (c == 2 || c == 5)) { Ps[r, c] = new Bishop(MYCOLOR.WHITE, "White_Bishop.png"); } else if (r == 0 && c == 3) { Ps[r, c] = new Queen(MYCOLOR.BLACK, "Black_Queen.png"); } else if (r == 7 && c == 3) { Ps[r, c] = new Queen(MYCOLOR.WHITE, "White_Queen.png"); } else if (r == 0 && c == 4) { Ps[r, c] = new King(MYCOLOR.BLACK, "Black_King.png"); } else if (r == 7 && c == 4) { Ps[r, c] = new King(MYCOLOR.WHITE, "White_King.png"); } else { Ps[r, c] = null; } MYCOLOR cc = (((r + c) % 2 == 0) ? MYCOLOR.WHITE : MYCOLOR.BLACK); Cs[r, c] = new Cell(r, c, cc, Ps[r, c], ChessPanel.Width, ChessPanel.Height, Dimension); Cs[r, c].Click += new System.EventHandler(CellSelected); ChessPanel.Controls.Add(Cs[r, c]); } } }