Beispiel #1
0
        public Game1()
        {
            Content.RootDirectory = "Content";
            _graphics             = new GraphicsDeviceManager(this)
            {
                PreferredBackBufferWidth  = 1280,
                PreferredBackBufferHeight = 720
            };
            Window.AllowUserResizing = true;
            IsMouseVisible           = true;

            _humanKeyboard = new HumanKeyboardControls();
            KeyboardEventRegistry.OnKeyDown(Keys.Enter, () =>
            {
                if (_useCpuKeyboard)
                {
                    _cpuGuyDecorator.Deactivate();
                }
                else
                {
                    _cpuGuyDecorator.Activate();
                }
                _useCpuKeyboard = !_useCpuKeyboard;
            });

            KeyboardEventRegistry.OnKeyDown(Keys.B, () =>
            {
                _guy.BoundingBox.ShouldDraw = !_guy.BoundingBox.ShouldDraw;
            });
        }
 public CpuGuyDecorator(Guy.Guy guy, SpriteFont font)
 {
     Guy              = guy;
     _font            = font;
     _controlPatterns = new CircularArray <CpuKeyboardControls>(
         CpuKeyboardControlsFactory.RunningCelebration(),
         CpuKeyboardControlsFactory.RunBackAndForth(),
         CpuKeyboardControlsFactory.Cannonball(),
         CpuKeyboardControlsFactory.JumpAndSquat());
     KeyboardEventRegistry.OnKeyDown(Keys.Left, OnLeft);
     KeyboardEventRegistry.OnKeyDown(Keys.Right, OnRight);
 }