private void PieceClick(object sender, EventArgs e) { RefressChessBoard(); //Get the properties of the picturebox selected CurrentPiece = (PictureBox)sender; if (PieceMove) { foreach (PictureBox chessPiece in AllPieces) { chessPiece.BackColor = Color.Transparent; chessPiece.Visible = false; } } if (!PromotePawn) { //get the x coordinate of the selected piece FromX = CurrentPiece.Left / 100; FromX = Convert.ToInt32(Math.Floor(FromX)); //get the y coordinate of the selected piece FromY = CurrentPiece.Top / 100; FromY = Convert.ToInt32(Math.Floor(FromY)); if (chessEngine.isPlayerPiece((byte)FromX, (byte)FromY)) { //Get the Piece that was selected PieceSelected = chessEngine.CurrentBoard.GetPieceAtPosition((byte)FromX, (byte)FromY); //Check if the player selected a pawn if (CurrentPiece.Name == enPieceType.WhitePawn.ToString() || CurrentPiece.Name == enPieceType.BlackPawn.ToString()) { PossibleMoves = chessEngine.GetMoves((byte)FromX, (byte)FromY); CurrentPiece.BackColor = Color.OliveDrab; PieceMove = true; } DisplayAllPossibleMoves(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)