/* Sets the initial checker placement */ private void InitializeCheckers(bool phase) { for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { // Determination of the coordinates and dimensions of the checker on the top CheckersCoordinateSet positionTop = new CheckersCoordinateSet( new Point((2 * j + ((i + 1) % 2)) * cellSize.Width, i * cellSize.Height), cellSize, new Point(2 * j + ((i + 1) % 2), i)); // Determining the coordinates and the size of the checker from the bottom CheckersCoordinateSet positionBottom = new CheckersCoordinateSet( new Point(7 * cellSize.Width - (((2 * j + ((i + 1) % 2)) * cellSize.Width)), 7 * cellSize.Height - i * cellSize.Height), cellSize, new Point(7 - (2 * j + ((i + 1) % 2)), 7 - i)); // Initializing a White Checker BaseChecker checker = new Pawn(CheckerSide.White, phase == true ? CheckerMoveDirection.Downstairs : CheckerMoveDirection.Upstairs, phase == true ? positionTop : positionBottom); state.AllCheckers.Add(checker); Game.drawingController.AddToDrawingList(checker); // Initializing the Black Checker checker = new Pawn(CheckerSide.Black, phase == false ? CheckerMoveDirection.Downstairs : CheckerMoveDirection.Upstairs, phase == false ? positionTop : positionBottom); state.AllCheckers.Add(checker); Game.drawingController.AddToDrawingList(checker); } } }
} // Combined position /* Determined by: * - the symbol of the marker * - position */ public BoardMarker(char marker, CheckersCoordinateSet position) { this.marker = marker; ZOrder = 2; this.Position = position; this.color = Constants.colorScheme.BoardMarkerColor; }
/* Determined by: * - Side (Black / White) * - Direction of travel (Up / Down / In both directions (king)) * - Combined position (Position on the screen, size on the screen, position on the board) */ public BaseChecker(CheckerSide side, CheckerMoveDirection direction, CheckersCoordinateSet position) { this.Side = side; this.Position = position; this.ZOrder = 1; this.Direction = direction; }
/* Initializes cells */ private void InitializeCells() { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { CheckersCoordinateSet position = new CheckersCoordinateSet( new Point(j * cellSize.Width, i * cellSize.Height), cellSize, new Point(j, i)); board[j, i] = new BoardCell(((i + j) % 2 == 0) ? false : true, position); Game.drawingController.AddToDrawingList(board[j, i]); } } }
/* Initializes markers (A, B, C, D...) */ private void InitializeMarkers() { for (int i = 0; i < 8; i++) { // Vertical markers CheckersCoordinateSet position = new CheckersCoordinateSet( new Point(2, i * cellSize.Height + (cellSize.Height / 2) - (cellSize.Height / 6)), new Size(12, 12), new Point(0, i)); markers[0, i] = new BoardMarker(Convert.ToChar('8' - i), position); Game.drawingController.AddToDrawingList(markers[0, i]); // Horizontal markers position = new CheckersCoordinateSet( new Point(i * cellSize.Width + (cellSize.Width / 2) - (cellSize.Width / 6), 8 * cellSize.Height - 18), new Size(12, 12), new Point(i, 0)); markers[1, i] = new BoardMarker(Convert.ToChar('A' + i), position); Game.drawingController.AddToDrawingList(markers[1, i]); } }
public King(CheckerSide side, CheckersCoordinateSet position) : base(side, CheckerMoveDirection.Both, position) { this.TurnRange = 8; // 8-cell move }
public Pawn(CheckerSide side, CheckerMoveDirection direction, CheckersCoordinateSet position) : base(side, direction, position) { this.TurnRange = 1; // Only walks 1 cell }