public void AddPlayer(EnhancedPlayer ePlayer) { eBoard[ePlayer.colPosition][ePlayer.rowPosition].enhancedBoardSpace = ePlayer; eBoard[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = ePlayer; board[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = ePlayer; prevDeco.AddPlayer(ePlayer); }
public void MovePlayerOneSquare(EnhancedPlayer ePlayer) { int i = 0; while (i < ePlayer.playerSpeed) { ePlayer.playerSpeed = ePlayer.playerSpeed + GetPowerNextSquare(eBoard, ePlayer); eBoard[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = null; eBoard[ePlayer.colPosition][ePlayer.rowPosition].enhancedBoardSpace = null; board[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = null; ePlayer.colPosition = GetNextColPosition(board, ePlayer); ePlayer.rowPosition = GetNextRowPosition(board, ePlayer); eBoard[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = ePlayer; eBoard[ePlayer.colPosition][ePlayer.rowPosition].enhancedBoardSpace = ePlayer; board[ePlayer.colPosition][ePlayer.rowPosition].boardSpace = ePlayer; prevDeco.MovePlayerOneSquare(ePlayer.prevDeco); i++; } }
static void Main(string[] args) { Console.WriteLine("Decorator Board Game Console Applications"); /* Create a square playing board 5 x 5 */ GamesBoard gamesBoard = new DefaultBoard(); /* Add player upon the board at 0,0 facing North */ Player playerOne = new DefaultPlayer("Player 1"); gamesBoard.AddPlayer(playerOne); gamesBoard.DisplayBoard(); /* Add inner walls to the game board*/ gamesBoard = new InnerWallBoard(gamesBoard, 2, 2, CompassPoints.NORTH); gamesBoard = new InnerWallBoard(gamesBoard, 2, 2, CompassPoints.EAST); gamesBoard.DisplayBoard(); /* Move player East by one square */ playerOne.Turn(Rotation.RIGHT); gamesBoard.MovePlayerOneSquare(playerOne); gamesBoard.DisplayBoard(); /* Move player North by ten squares */ playerOne.Turn(Rotation.LEFT); for (int i = 0; i < 10; i++) { gamesBoard.MovePlayerOneSquare(playerOne); gamesBoard.DisplayBoard(); } gamesBoard.DisplayBoard(); /* Move player East by ten squares */ playerOne.Turn(Rotation.RIGHT); for (int i = 0; i < 10; i++) { gamesBoard.MovePlayerOneSquare(playerOne); } gamesBoard.DisplayBoard(); /* Make Enhanced Games Board*/ EnhancedBoard enhancedGamesBoard = new EnhancedBoard(gamesBoard); /* Add Power Item to the board */ Console.WriteLine("\nAdd Power Cookie to the new board"); EnhancedPlayer cookieOne = new EnhancedPlayer("Cookie 1", 0, 1, 1); enhancedGamesBoard.AddPlayer(cookieOne); enhancedGamesBoard.DisplayBoard(); /* Make player 2 to eat cookies */ EnhancedPlayer enhancedPlayerOne = new EnhancedPlayer(playerOne); enhancedGamesBoard.AddPlayer(enhancedPlayerOne); enhancedGamesBoard.DisplayBoard(); /* Move player west by four squares */ enhancedPlayerOne.Turn(Rotation.LEFT); enhancedPlayerOne.Turn(Rotation.LEFT); for (int i = 0; i < 4; i++) { enhancedGamesBoard.MovePlayerOneSquare(enhancedPlayerOne); } gamesBoard.DisplayBoard(); enhancedGamesBoard.DisplayBoard(); /* Move player 1 South by three square */ enhancedPlayerOne.Turn(Rotation.LEFT); for (int i = 0; i < 3; i++) { enhancedGamesBoard.MovePlayerOneSquare(enhancedPlayerOne); } enhancedGamesBoard.MovePlayerOneSquare(enhancedPlayerOne); enhancedGamesBoard.DisplayBoard(); /* Move player 1 East by one square */ enhancedPlayerOne.Turn(Rotation.LEFT); for (int i = 0; i < 1; i++) { enhancedGamesBoard.MovePlayerOneSquare(enhancedPlayerOne); } enhancedGamesBoard.MovePlayerOneSquare(enhancedPlayerOne); enhancedGamesBoard.DisplayBoard(); Console.WriteLine("\nPress Any Key To Continue . . . "); Console.ReadKey(); }
public int GetPowerNextSquare(List <List <EnhancedSquare> > eBoard, EnhancedPlayer ePlayer) { int nextCol = ePlayer.colPosition; int nextRow = ePlayer.rowPosition; int powerPoints = 0; switch (ePlayer.facingDirection) { case CompassPoints.NORTH: if (!board[ePlayer.colPosition][ePlayer.rowPosition].northWall) { nextRow++; } else { return(powerPoints); } break; case CompassPoints.SOUTH: if (!board[ePlayer.colPosition][ePlayer.rowPosition].southWall) { nextRow--; } else { return(powerPoints); } break; case CompassPoints.WEST: if (!board[ePlayer.colPosition][ePlayer.rowPosition].westWall) { nextCol--; } else { return(powerPoints); } break; case CompassPoints.EAST: if (!board[ePlayer.colPosition][ePlayer.rowPosition].eastWall) { nextCol++; } else { return(powerPoints); } break; default: break; } if (eBoard[nextCol][nextRow].enhancedBoardSpace != null) { powerPoints = eBoard[nextCol][nextRow].enhancedBoardSpace.playerSpeed; } return(powerPoints); }