public KeyboardController(MarioGame game)
        {
            this.game = game;

            downActions    = new Dictionary <Keys, Action>();
            pressActions   = new Dictionary <Keys, Action>();
            releaseActions = new Dictionary <Keys, Action>();

            previous = Keyboard.GetState();

            this.OnKeyPressed(Keys.Q, game.Exit);
            this.OnKeyPressed(Keys.R, game.LevelReset);
            this.OnKeyPressed(Keys.M, game.MenuReset);
            this.OnKeyPressed(Keys.Enter, InputActions.start);

            this.OnKeyPressed(Keys.Up, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));
            this.OnKeyPressed(Keys.W, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));
            this.OnKeyPressed(Keys.Space, ActionUtil.Chain(InputActions.jump, InputActions.menuUp));

            this.OnKeyDownRelease(Keys.Left, InputActions.moveLeft, InputActions.halt);
            this.OnKeyDownRelease(Keys.A, InputActions.moveLeft, InputActions.halt);
            this.OnKeyDownRelease(Keys.Right, InputActions.moveRight, InputActions.halt);
            this.OnKeyDownRelease(Keys.D, InputActions.moveRight, InputActions.halt);

            this.OnKeyPressed(Keys.F, InputActions.fire);

            this.OnKeyDown(Keys.Down, InputActions.crouch);
            this.OnKeyDown(Keys.S, InputActions.crouch);


            this.OnKeyPressed(Keys.Down, InputActions.menuDown);
            this.OnKeyPressed(Keys.S, InputActions.menuDown);
        }
示例#2
0
        public GamePadController(MarioGame game)
        {
            this.game = game;
            previous  = GamePad.GetState(PlayerIndex.One);

            downActions    = new Dictionary <Buttons, Action>();
            pressActions   = new Dictionary <Buttons, Action>();
            releaseActions = new Dictionary <Buttons, Action>();

            this.OnButtonPressed(Buttons.Start, game.Quit);

            this.OnButtonPressRelease(Buttons.DPadUp, ActionUtil.Chain(InputActions.jump, InputActions.menuUp), InputActions.halt);
            this.OnButtonDownRelease(Buttons.DPadDown, InputActions.crouch, InputActions.halt);
            this.OnButtonDownRelease(Buttons.DPadLeft, InputActions.moveLeft, InputActions.halt);
            this.OnButtonDownRelease(Buttons.DPadRight, InputActions.moveRight, InputActions.halt);

            this.OnButtonPressed(Buttons.A, InputActions.fire);
            this.OnButtonPressed(Buttons.DPadDown, InputActions.menuDown);
        }