Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        public void InvokeState()
        {
            var level     = levelFactory.CreateLevel();
            var inputLoop = new InputLoop();
            var playView  = new VoidView();

            var inputController = new ServerInputController(level, newSessionId, inputService);

            var exitGameInteractor   = new ExitGameInteractor(level, inputController);
            var playerMoveInteractor = new PlayerMoveInteractor(level, playView, inputController);
            var mobMoveInteractor    = new MobMoveInteractor(level, playView, inputController);
            var inventoryInteractor  = new InventoryInteractor(level, playView);

            levelFactory.SetPlayerFactory(new NetworkPlayerFactory(exitGameInteractor));

            var moveProcessor      = new MoveProcessor(playerMoveInteractor);
            var exitGameProcessor  = new ExitGameProcessor(exitGameInteractor);
            var inventoryProcessor = new InventoryProcessor(inventoryInteractor, inputController);

            var tickController = new TickController();

            inputController.AddInputProcessor(moveProcessor);
            inputController.AddInputProcessor(inventoryProcessor);
            inputController.AddInputProcessor(exitGameProcessor);

            inputLoop.AddFixedUpdatable(tickController);
            inputLoop.AddUpdatable(inputController);

            level.CurrentPlayer = new Player(DummyLogin, level, new Position(-1, -1));

            var mobs = level.Mobs;

            foreach (var mob in mobs)
            {
                var mobMoveProcessor = new MobMoveProcessor(mob, mobMoveInteractor);
                tickController.AddTickProcessor(mobMoveProcessor);
                mob.OnDie += (sender, args) =>
                {
                    level.Mobs.Remove(mob);
                    tickController.RemoveTickProcessor(mobMoveProcessor);
                };
            }

            inputLoop.Start();
        }
Ejemplo n.º 3
0
        public void InvokeState()
        {
            var level     = levelFactory.CreateLevel();
            var inputLoop = new InputLoop();
            var playView  = new ConsolePlayView();

            var moveInteractor     = new MoveInteractor(level, playView);
            var exitGameInteractor = new ExitGameInteractor(inputLoop);

            var moveProcessor     = new MoveProcessor(moveInteractor);
            var exitGameProcessor = new ExitGameProcessor(exitGameInteractor);

            var keyboardController = new KeyboardController();

            keyboardController.AddInputProcessor(moveProcessor);
            keyboardController.AddInputProcessor(exitGameProcessor);

            inputLoop.AddUpdatable(keyboardController);

            playView.Draw(level);
            inputLoop.Start();
        }