private bool checkIfValidTurnAndPreformIt(int i_ColDestination, int i_RowDestination) { bool isValidTurn = false; CheckersLogic.Point startingPoint = new CheckersLogic.Point(boardSquareActiveSquare.Row, boardSquareActiveSquare.Col); CheckersLogic.Point destinationPoint = new CheckersLogic.Point(i_RowDestination, i_ColDestination); if (r_LogicUnit.PreformMove(startingPoint, destinationPoint) == true) { isValidTurn = true; } else { MessageBox.Show( @"Invalid move! Please try again.", this.Text); boardSquareActiveSquare.SetInActive(); boardSquareActiveSquare = null; } return(isValidTurn); }
private void boardSquare_Clicked(object sender, EventArgs e) { BoardSquare clickedSquare = sender as BoardSquare; if (clickedSquare.Enabled == true) { if (boardSquareActiveSquare == null && clickedSquare.BoardSquareType != BoardSquare.eBoardSquareType.None) { // board has no active square clickedSquare.SetActive(); boardSquareActiveSquare = clickedSquare; } else if (boardSquareActiveSquare != null) { // board has an active square, check if its a move or we click on the same square again to inactive if (clickedSquare == boardSquareActiveSquare) { clickedSquare.SetInActive(); boardSquareActiveSquare = null; } else { // if we got to here, that means the user wanted to make a move // Human turn handleHumanTurn(clickedSquare); // Initialize the timer before computer turn if (r_LogicUnit.Mode == LogicUnit.eGameMode.PlayerVsComputer) { r_Timer.Start(); } // update the boards graphics updateBoardGraphics(); } } } }