public void SetupGame(int Level) { // Create Game Board gameboard.CreateBoardImage(this, Level); // Create Board Matrix Tuple <int, int> PacmanStartCoordinates = gameboard.InitialiseBoardMatrix(Level); // Create Player player.CreatePlayerDetails(this); player.CreateLives(this); // Create Form Elements formelements.CreateFormElements(this); // Create High Score highscore.CreateHighScore(this); // Create Food food.CreateFoodImages(this); // Create Ghosts ghost.CreateGhostImage(this); // Create Pacman pacman.CreatePacmanImage(this, PacmanStartCoordinates.Item1, PacmanStartCoordinates.Item2); }
public void SetupGame() { food.RemoveFoodImages(this); player = new Player(); pacman.SetFormElement(formelements); // Create Game Board gameboard.CreateBoardImage(this, 1); // Create Board Matrix Tuple <int, int> PacmanStartCoordinates = gameboard.InitialiseBoardMatrix(1); player.RemoveLives(this); // Create Player player.CreatePlayerDetails(this); player.CreateLives(this); // Create Form Elements formelements.CreateFormElements(this); // Create High Score highscore.CreateHighScore(this); // Create Food food.CreateFoodImages(this); // Create Ghosts ghost.CreateGhostImage(this); // Create Pacman` pacman.RemovePacmanImage(this, PacmanStartCoordinates.Item1, PacmanStartCoordinates.Item2); pacman.CreatePacmanImage(this, PacmanStartCoordinates.Item1, PacmanStartCoordinates.Item2); }
public void GameBoardMatrixTest() { // Check Board Matrix for start position Assert.AreEqual(new Tuple <int, int> (9, 17), GameBoard.InitialiseBoardMatrix(1)); }
private void Form1_Load(object sender, EventArgs e) { _signalR.RegisterPlayer(); // Create Board Matrix Tuple <int, int> PacmanStartCoordinates = gameboard.InitialiseBoardMatrix(1); SetupGame(1); playerData.RegisterObserver(player); playerData.RegisterObserver(highscore); _hubConnection.On("ReceiveRegisterCompletedMessage", () => { facade.Log.AppendText($"\nWait until your friend opens this game then press F1 to join the game!\n" + $"Player1 plays with blue pacman, Player2 plays with red.\n"); facade.Log.AppendText($"\nPlayer lives: {player.Lives}"); }); _hubConnection.On <string>("ReceiveConnectedMessage", (connnectionId) => { this.Invoke((Action)(() => { Player newPlayer = new Player(connnectionId, "Player" + (players.Count + 1)); _api.CreatePlayer(newPlayer); players.Add(newPlayer); if (players.Count == 2) { // Decrator pacman = blueFactory.CreatePacman(_signalR, players.First().Id); //pacman = new PinkBorderDecorator(pacman); pacman.AddPacmanImages(); opponent = redFactory.CreatePacman(_signalR, players.Last().Id); opponent.AddPacmanImages(); pacmans.Add(pacman); pacmans.Add(opponent); moveUp = new MoveUpCommand(opponent); moveDown = new MoveDownCommand(opponent); moveRight = new MoveRightCommand(opponent); moveLeft = new MoveLeftCommand(opponent); ghost.EnableTimer(); foreach (var p in pacmans) { p.CreatePacmanImage(this, PacmanStartCoordinates.Item1, PacmanStartCoordinates.Item2); p.EnableTImer(); } // For Observer testing playerData.EditLives(5); facade.Log.AppendText($"\nPlayer lives: {player.Lives}"); } facade.Log.AppendText($"\n{newPlayer.Name} with id {connnectionId} joined the game!" + $"\nTotal players: {players.Count}"); })); }); _hubConnection.On <int, int, int, string>("ReceivePacmanCoordinates", (xCoordinate, yCoordinate, direction, id) => { this.Invoke((Action)(() => { // Logging movement Pacman currentPacman = pacmans.Single(p => p.Id == id); Player currentPlayer = players.Single(p => p.Id == id); _pacmanLogAdapter = new PacmanLogAdapter(currentPacman); _playerLogAdapter = new PlayerLogAdapter(currentPlayer); _fileLogger.LogData(string.Format("pacman ID: {0} | xCoordinate:{1} | yCordinate:{2} | date:{3}", currentPacman.Id, currentPacman.xCoordinate, currentPacman.yCoordinate, DateTime.UtcNow)); _pacmanLogAdapter.LogData(null); _playerLogAdapter.LogData(null); facade.Log.ScrollToCaret(); pacmans.Single(p => p.Id == id).nextDirection = direction; })); }); }