Пример #1
0
        public void Play()
        {
            _world = new World(_mapLoader.Load(0));

            while (true)
            {
                if (RequiresRedraw)
                {
                    _gameRender.Draw(_world);
                    RequiresRedraw = false;
                }

                bool wantsToQuit = GetInput();
                if (wantsToQuit)
                {
                    break;
                }


                if (!_world.AnyUnsolvedBarrels())
                {
                    _gameRender.Draw(_world);
                    _gameRender.DrawWin();
                    break;
                }
            }
        }
Пример #2
0
 public override Task Run(IGameContext context, CancellationToken token)
 {
     _map = _mapLoader.Load("Levels", "*.cshtml").First();
     _eventSink.Subscribe <ConsoleKeyPressedEvent>(new MovementHandler(_gameState).Handle);
     _eventSink.Subscribe <PelletEaten>(new FoodMonitorHandler(_map, this).Handle);
     _eventSink.Subscribe <CherryEaten>(new FoodMonitorHandler(_map, this).Handle);
     _renderer.Render(_map.ToSprite(new Offset(0, 0)));
     _lastUpdateTime = DateTime.Now;
     return(base.Run(context, token));
 }