public void UpdateGhostLocation(Ghost ghost, PacPersonLocation ghostLocation) { int row = ghostLocation.Row; int column = ghostLocation.Column; switch (ghost.CurrentDirection) { case Direction.Left: if (ghostLocation.Row == 12 && ghostLocation.Column == 0) { MoveGhostLocation(ghostLocation, 12, Board.BOARD_DEMENSION_COLUMN - 1); } else if (GameBoard[row, column - 1] != '█' && GameBoard[row, column - 1] != '▄' && GameBoard[row, column - 1] != '▀') { MoveGhostLocation(ghostLocation, row, column - 1); } else { ghost.UpdateGhostDirection(); } break; case Direction.Up: if (GameBoard[row - 1, column] != '▄' && GameBoard[row - 1, column] != '▀' && GameBoard[row - 1, column] != '█') { MoveGhostLocation(ghostLocation, row - 1, column); } else { ghost.UpdateGhostDirection(); } break; case Direction.Right: if (ghostLocation.Row == 12 && ghostLocation.Column == Board.BOARD_DEMENSION_COLUMN - 1) { MoveGhostLocation(ghostLocation, 12, 0); } else if (GameBoard[row, column + 1] != '█' && GameBoard[row, column + 1] != '▄' && GameBoard[row, column + 1] != '▀') { MoveGhostLocation(ghostLocation, row, column + 1); } else { ghost.UpdateGhostDirection(); } break; case Direction.Down: if (GameBoard[row + 1, column] != '█' && GameBoard[row + 1, column] != '▄' && GameBoard[row + 1, column] != '▀') { MoveGhostLocation(ghostLocation, row + 1, column); } else { ghost.UpdateGhostDirection(); } break; } }
public void MovePacPersonAndEmptyPreviousLocation(int row, int column) { WriteAt(" ", CurrentPacPersonLocation.Row, CurrentPacPersonLocation.Column); GameBoard[CurrentPacPersonLocation.Row, CurrentPacPersonLocation.Column] = ' '; CurrentPacPersonLocation = new PacPersonLocation(row, column); DecrementCookiesIfNeeded(CurrentPacPersonLocation.Row, CurrentPacPersonLocation.Column); WriteAt("O", CurrentPacPersonLocation.Row, CurrentPacPersonLocation.Column); }
public Board(PacPerson pacPerson, Ghost ghostOne, Ghost ghostTwo, Ghost ghostThree) { GameBoard = CreateBoard(); PacPerson = pacPerson; GhostOne = ghostOne; GhostOne = ghostTwo; GhostOne = ghostThree; CurrentPacPersonLocation = new PacPersonLocation(BOARD_DEMENSION_ROW - 2, 1); CurrentGhostOneLocation = new PacPersonLocation(1, BOARD_DEMENSION_COLUMN - 2); CurrentGhostTwoLocation = new PacPersonLocation(1, 1); CurrentGhostThreeLocation = new PacPersonLocation(BOARD_DEMENSION_ROW - 2, BOARD_DEMENSION_COLUMN - 2); Cookies = INITIAL_COOKIES; }
public void MoveGhostLocation(PacPersonLocation ghostLocation, int row, int column) { char currentBoardState = GameBoard[ghostLocation.Row, ghostLocation.Column]; if (currentBoardState == '\u263A') { WriteAt(" ", ghostLocation.Row, ghostLocation.Column); } else { WriteAt(currentBoardState.ToString(), ghostLocation.Row, ghostLocation.Column); } ghostLocation.Row = row; ghostLocation.Column = column; WriteAt("\u263A", ghostLocation.Row, ghostLocation.Column); }
public void AddPacPersonToBoard(PacPersonLocation currentLocation, char symbol) { GameBoard[currentLocation.Row, currentLocation.Column] = symbol; Cookies = Cookies - 1; // because pacPerson will 'eat' the cookie at its startig location }