////////////////////// DRAWING //////////////////// /// <summary> /// DrawSquare method /// </summary> /// <param name="g"></param> /// <param name="aChessSquare"></param> /// <param name="aIsHighlight"></param> /// <param name="aIsLastMove"></param> private void DrawSquare(Graphics g, ChessSquare aChessSquare, bool aIsHighlight, bool aIsLastMove) { if (aChessSquare != null) { aChessSquare.Draw(g, squareFactory, aIsHighlight, aIsLastMove); ChessPiece chessPiece = (ChessPiece)aChessSquare.GetChessPiece(); DrawPiece(g, chessPiece); } }
/// <summary> /// GetChessPieceAtSquare method /// </summary> /// <param name="square"></param> /// <returns>ChessPiece</returns> private ChessPiece GetChessPieceAtSquare(ChessSquare square) { if (square != null) { ChessPiece chessPiece = (ChessPiece)square.GetChessPiece(); if (chessPiece != null) return chessPiece; else return null; } else return null; }
/// <summary> /// MovePiece method /// </summary> /// <param name="aMovingPiece"></param> /// <param name="aSquare"></param> /// <param name="aoriginalSquare"></param> /// <returns>bool</returns> public bool MovePiece(ChessPiece aMovingPiece, ChessSquare aSquare, ChessSquare aoriginalSquare) { // if new square contains a piece, make that piece's square to null ChessPiece aCapturedPiece = aSquare.GetChessPiece(); // Move the Piece RealMove(aMovingPiece, aSquare, aoriginalSquare); // Set Piece's Start Position aMovingPiece.SetStartLocation(new Point(aSquare.GetStartLocation().X + ChessImageConstants.ChessPieceLeft, aSquare.GetStartLocation().Y + ChessImageConstants.ChessPieceTop)); return true; }