public void SpawnPlayerInteractorTest() { var playerView = new VoidView(); var spawnPlayerInteractor = new SpawnPlayerInteractor(level, playerView); spawnPlayerInteractor.Spawn(new Position(1, 1), "newplayer"); Assert.IsTrue(level.ContainsPlayer("newplayer")); spawnPlayerInteractor.DeletePlayer("newplayer"); Assert.IsFalse(level.ContainsPlayer("newplayer")); }
public void InvokeState() { var playView = new ConsolePlayView(); var level = client.Login(login, sessionId); if (level == null) { throw new ArgumentException("Login already exists."); } var inputLoop = new InputLoop(); var playerMoveInteractor = new NetworkPlayerMoveInteractor(level, playView); var mobMoveInteractor = new NetworkMobMoveInteractor(level, playView); var exitGameInteractor = new ExitGameInteractor(level); var inventoryInteractor = new InventoryInteractor(level, playView); var spawnPlayerInteractor = new SpawnPlayerInteractor(level, playView); var moveProcessor = new MoveProcessor(playerMoveInteractor); var exitGameProcessor = new ExitGameProcessor(exitGameInteractor); var inventoryProcessor = new InventoryProcessor(inventoryInteractor); var keyboardController = new KeyboardController(level, login); keyboardController.AddInputProcessor(client); keyboardController.AddInputProcessor(exitGameProcessor); client.AddInputProcessor(moveProcessor); client.AddInputProcessor(exitGameProcessor); client.AddInputProcessor(inventoryProcessor); client.SetMobInteractor(mobMoveInteractor); client.SetPlayerMoveInteractor(playerMoveInteractor); client.SetSpawnPlayerInteractor(spawnPlayerInteractor); inputLoop.AddUpdatable(keyboardController); inputLoop.AddUpdatable(client); level.CurrentPlayer = level.GetPlayer(login); level.CurrentPlayer.OnDie += (sender, args) => { inputLoop.Stop(); }; exitGameInteractor.OnExit += (sender, player) => { inputLoop.Stop(); }; playView.Draw(level); inputLoop.Start(); }