예제 #1
0
        public DefaultKeyboardController(Game1 myGame)
        {
            game = myGame;

            int playerNumber = 0;

            idleCommand       = new MarioIdleCommand(playerNumber);
            NonPressedCommand = new NonPressedKeyMarioCommand(playerNumber);

            controllerMappings = new Dictionary <Keys, ICommand>
            {
                { Keys.Q, new ExitGameCommand() },
                { Keys.W, new MarioUpCommand(playerNumber) },
                { Keys.A, new MarioLeftCommand(playerNumber) },
                { Keys.Left, new MarioLeftCommand(playerNumber) },
                { Keys.Right, new MarioRightCommand(playerNumber) },
                { Keys.Up, new MarioUpCommand(playerNumber) },
                { Keys.Down, new MarioDownCommand(playerNumber) },
                { Keys.S, new MarioDownCommand(playerNumber) },
                { Keys.D, new MarioRightCommand(playerNumber) },
                { Keys.R, new ResetAllCommand() },
                { Keys.I, new SwitchToFireMarioCommand(playerNumber) },
                { Keys.Y, new SwitchToSmallMarioCommand(playerNumber) },
                { Keys.O, new KillMarioCommand(playerNumber) },
                { Keys.U, new SwitchToBigMarioCommand(playerNumber) },
                { Keys.X, new MarioRunningCommand(playerNumber) },
                { Keys.N, new NightmareModeCommand(playerNumber) },
                { Keys.J, new JumpOnlyModeCommand(playerNumber) },
                { Keys.L, new LevelEditorCommand() },
                { Keys.H, new ReplayCommander() }
            };
        }
        public EditingKeyboardController(Game1 myGame, CameraController camera)
        {
            game    = myGame;
            textBox = EditLevelDisplay.saveTextBox;

            int playerNumber = 0;

            idleCommand       = new MarioIdleCommand(playerNumber);
            NonPressedCommand = new NonPressedKeyMarioCommand(playerNumber);

            ResetTimer();

            controllerMappings = new Dictionary <Keys, ICommand>
            {
                { Keys.W, new CameraUpCommand(camera) },
                { Keys.A, new CameraLeftCommand(camera) },
                { Keys.Left, new CameraLeftCommand(camera) },
                { Keys.Right, new CameraRightCommand(camera) },
                { Keys.Up, new CameraUpCommand(camera) },
                { Keys.Down, new CameraDownCommand(camera) },
                { Keys.S, new CameraDownCommand(camera) },
                { Keys.D, new CameraRightCommand(camera) },
                { Keys.B, new LevelEditorCommand() }
            };
        }
예제 #3
0
        public void Update(GameTime gameTime)
        {
            GamePadState gamePadState = GamePad.GetState(PlayerIndex.One);

            foreach (Buttons button in Enum.GetValues(typeof(Buttons)))
            {
                if (gamePadState.IsConnected && controllerMappings.ContainsKey(button) && gamePadState.IsButtonDown(button))
                {
                    controllerMappings[button].Execute(game);
                }
            }

            if (gamePadState.IsConnected)
            {
                float xDirection = gamePadState.ThumbSticks.Left.X;
                float yDirection = gamePadState.ThumbSticks.Left.Y;

                bool isIdle = true;

                if (xDirection > variance)
                {
                    MarioRightCommand marioRightCmd = new MarioRightCommand(playerNumber);
                    marioRightCmd.Execute(this.game);
                    isIdle = false;
                }
                else if (xDirection < (-1 * variance))
                {
                    MarioLeftCommand marioLeftCmd = new MarioLeftCommand(playerNumber);
                    marioLeftCmd.Execute(this.game);
                    isIdle = false;
                }

                if (yDirection > variance)
                {
                }
                else if (yDirection < (-1 * variance))
                {
                    MarioDownCommand marioDownCmd = new MarioDownCommand(playerNumber);
                    marioDownCmd.Execute(this.game);
                    isIdle = false;
                }

                if (isIdle)
                {
                    MarioIdleCommand marioIdleCmd = new MarioIdleCommand(playerNumber);
                    marioIdleCmd.Execute(this.game);
                }
            }
        }
예제 #4
0
        public GamerReplayer(Game1 game)
        {
            this.srReadFile    = new StreamReader(strReadFilePath);
            this.game          = game;
            idleCommand        = new MarioIdleCommand(playerNumber);
            NonPressedCommand  = new NonPressedKeyMarioCommand(playerNumber);
            LogCommandMappings = new Dictionary <String, ICommand>
            {
                { "Q", new ExitGameCommand() },
                { "W", new MarioUpCommand(playerNumber) },
                { "A", new MarioLeftCommand(playerNumber) },

                { "D", new MarioRightCommand(playerNumber) },

                { "X", new MarioRunningCommand(playerNumber) },
            };
        }