static Game() { Playing = false; Marked = false; RedCount = 0; BlackCount = 0; OldPosition = new Piece(); GameLog = new List<Move>(); RCapturedPiece = new List<CapturedPiece>(); BCapturedPiece = new List<CapturedPiece>(); Players[0] = new Player(0); Players[1] = new Player(1); // // Capture king alert // PbCaptureKing.BackColor = Color.Transparent; PbCaptureKing.Image = Resources.CaptureKingAlert; PbCaptureKing.Width = 160; PbCaptureKing.Height = 70; PbCaptureKing.Top = 60; PbCaptureKing.Left = 450; PbCaptureKing.Visible = false; // // GameOver Panel // PbGameOver.BackColor = Color.Transparent; PbGameOver.Image = Resources.Gameover; PbGameOver.Size = new Size(160, 70); //PbGameOver.Controls.Add(); //PbGameOver.Controls.Add(); PbGameOver.Top = 60; PbGameOver.Left = 450; PbGameOver.Visible = false; // // RedTurn // RedTurn.SizeMode = PictureBoxSizeMode.Zoom; RedTurn.BackColor = Color.Transparent; RedTurn.Width = 30; RedTurn.Height = 30; RedTurn.Top = 340; RedTurn.Left = 600; RedTurn.Image = Resources.Turning; // // BlackTurn // BlackTurn.SizeMode = PictureBoxSizeMode.Zoom; BlackTurn.BackColor = Color.Transparent; BlackTurn.Width = 30; BlackTurn.Height = 30; BlackTurn.Top = 140; BlackTurn.Left = 600; BlackTurn.Image = Resources.NotTurn; // // btnGameOver // btnGameOver.BackColor = Color.NavajoWhite; btnGameOver.FlatAppearance.BorderColor = Color.DarkKhaki; btnGameOver.FlatStyle = FlatStyle.Flat; btnGameOver.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((163))); btnGameOver.Location = new Point(567, 34); btnGameOver.Size = new Size(69, 23); btnGameOver.TabIndex = 9; btnGameOver.Text = "Chịu thua"; btnGameOver.UseVisualStyleBackColor = false; btnGameOver.Visible = false; // // btnTurnAgain // btnTurnAgain.BackColor = Color.NavajoWhite; btnTurnAgain.FlatAppearance.BorderColor = Color.DarkKhaki; btnTurnAgain.FlatStyle = FlatStyle.Flat; btnTurnAgain.Font = new Font("Segoe UI", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((163))); btnTurnAgain.Location = new Point(491, 34); btnTurnAgain.Size = new Size(69, 23); btnTurnAgain.TabIndex = 10; btnTurnAgain.Text = "Đi lại"; btnTurnAgain.UseVisualStyleBackColor = false; btnTurnAgain.Visible = false; }
public static void NewGame() { switch (Playing) { case true: // Delete all pieces in chessboard Players[0].KingPiece.PbPiece.Visible = false; Players[0].AdvisorPieces[0].PbPiece.Visible = false; Players[0].AdvisorPieces[1].PbPiece.Visible = false; Players[0].ElephantPieces[0].PbPiece.Visible = false; Players[0].ElephantPieces[1].PbPiece.Visible = false; Players[0].ChariotPieces[0].PbPiece.Visible = false; Players[0].ChariotPieces[1].PbPiece.Visible = false; Players[0].CannonPieces[0].PbPiece.Visible = false; Players[0].CannonPieces[1].PbPiece.Visible = false; Players[0].HorsePieces[0].PbPiece.Visible = false; Players[0].HorsePieces[1].PbPiece.Visible = false; Players[0].SoldierPieces[0].PbPiece.Visible = false; Players[0].SoldierPieces[1].PbPiece.Visible = false; Players[0].SoldierPieces[2].PbPiece.Visible = false; Players[0].SoldierPieces[3].PbPiece.Visible = false; Players[0].SoldierPieces[4].PbPiece.Visible = false; Players[1].KingPiece.PbPiece.Visible = false; Players[1].AdvisorPieces[0].PbPiece.Visible = false; Players[1].AdvisorPieces[1].PbPiece.Visible = false; Players[1].ElephantPieces[0].PbPiece.Visible = false; Players[1].ElephantPieces[1].PbPiece.Visible = false; Players[1].ChariotPieces[0].PbPiece.Visible = false; Players[1].ChariotPieces[1].PbPiece.Visible = false; Players[1].CannonPieces[0].PbPiece.Visible = false; Players[1].CannonPieces[1].PbPiece.Visible = false; Players[1].HorsePieces[0].PbPiece.Visible = false; Players[1].HorsePieces[1].PbPiece.Visible = false; Players[1].SoldierPieces[0].PbPiece.Visible = false; Players[1].SoldierPieces[1].PbPiece.Visible = false; Players[1].SoldierPieces[2].PbPiece.Visible = false; Players[1].SoldierPieces[3].PbPiece.Visible = false; Players[1].SoldierPieces[4].PbPiece.Visible = false; Array.Resize(ref Players, 0); // Create new 2 players Array.Resize(ref Players, 2); Players[0] = new Player(0); Players[1] = new Player(1); // Create empty chess board Board.ResetBoard(); Turn = 1; Winner = -1; TurnCount = 0; BlackCount = 0; RedCount = 0; PbCaptureKing.Visible = false; PbGameOver.Visible = false; RedTurn.Image = Resources.Turning; BlackTurn.Image = Resources.NotTurn; // Draw pieces Players[0].KingPiece.Draw(); Players[0].AdvisorPieces[0].Draw(); Players[0].AdvisorPieces[1].Draw(); Players[0].ElephantPieces[0].Draw(); Players[0].ElephantPieces[1].Draw(); Players[0].ChariotPieces[0].Draw(); Players[0].ChariotPieces[1].Draw(); Players[0].CannonPieces[0].Draw(); Players[0].CannonPieces[1].Draw(); Players[0].HorsePieces[0].Draw(); Players[0].HorsePieces[1].Draw(); Players[0].SoldierPieces[0].Draw(); Players[0].SoldierPieces[1].Draw(); Players[0].SoldierPieces[2].Draw(); Players[0].SoldierPieces[3].Draw(); Players[0].SoldierPieces[4].Draw(); Players[1].KingPiece.Draw(); Players[1].AdvisorPieces[0].Draw(); Players[1].AdvisorPieces[1].Draw(); Players[1].ElephantPieces[0].Draw(); Players[1].ElephantPieces[1].Draw(); Players[1].ChariotPieces[0].Draw(); Players[1].ChariotPieces[1].Draw(); Players[1].CannonPieces[0].Draw(); Players[1].CannonPieces[1].Draw(); Players[1].HorsePieces[0].Draw(); Players[1].HorsePieces[1].Draw(); Players[1].SoldierPieces[0].Draw(); Players[1].SoldierPieces[1].Draw(); Players[1].SoldierPieces[2].Draw(); Players[1].SoldierPieces[3].Draw(); Players[1].SoldierPieces[4].Draw(); break; case false: // new game // Create empty chess board Board.ResetBoard(); Playing = true; // Draw pieces Players[0].KingPiece.Draw(); Players[0].AdvisorPieces[0].Draw(); Players[0].AdvisorPieces[1].Draw(); Players[0].ElephantPieces[0].Draw(); Players[0].ElephantPieces[1].Draw(); Players[0].ChariotPieces[0].Draw(); Players[0].ChariotPieces[1].Draw(); Players[0].CannonPieces[0].Draw(); Players[0].CannonPieces[1].Draw(); Players[0].HorsePieces[0].Draw(); Players[0].HorsePieces[1].Draw(); Players[0].SoldierPieces[0].Draw(); Players[0].SoldierPieces[1].Draw(); Players[0].SoldierPieces[2].Draw(); Players[0].SoldierPieces[3].Draw(); Players[0].SoldierPieces[4].Draw(); Players[1].KingPiece.Draw(); Players[1].AdvisorPieces[0].Draw(); Players[1].AdvisorPieces[1].Draw(); Players[1].ElephantPieces[0].Draw(); Players[1].ElephantPieces[1].Draw(); Players[1].ChariotPieces[0].Draw(); Players[1].ChariotPieces[1].Draw(); Players[1].CannonPieces[0].Draw(); Players[1].CannonPieces[1].Draw(); Players[1].HorsePieces[0].Draw(); Players[1].HorsePieces[1].Draw(); Players[1].SoldierPieces[0].Draw(); Players[1].SoldierPieces[1].Draw(); Players[1].SoldierPieces[2].Draw(); Players[1].SoldierPieces[3].Draw(); Players[1].SoldierPieces[4].Draw(); RedTurn.Image = Resources.Turning; BlackTurn.Image = Resources.NotTurn; break; } }