public SprintProxy(IStateProxy playerState, IToggleProxyCrouchMediator crouchProxyToggleMediator)
 {
     _IsInputActive        = false;
     _StatePlayer          = playerState;
     _CommandSprint        = new SprintCommand();
     _CrouchToggleMediator = crouchProxyToggleMediator;
     _WalkInput            = Vector3.zero;
 }
예제 #2
0
        public void Update()
        {
            gamePadState = GamePad.GetState(PlayerIndex.One);
            ICommand command;
            ICommand idleCommand = new IdleMarioCommand(Game1.Instance);

            if (gamePadState.IsButtonDown(Buttons.A) || gamePadState.IsButtonDown(Buttons.B) || gamePadState.IsButtonDown(Buttons.DPadLeft) || gamePadState.IsButtonDown(Buttons.DPadRight) ||
                gamePadState.IsButtonDown(Buttons.DPadUp) || gamePadState.IsButtonDown(Buttons.DPadDown) || gamePadState.ThumbSticks.Left.X > 0.5f || gamePadState.ThumbSticks.Left.X < -0.5f ||
                gamePadState.ThumbSticks.Left.Y > 0.5f || gamePadState.ThumbSticks.Left.X < -0.5f || gamePadState.IsButtonDown(Buttons.Back) || gamePadState.IsButtonDown(Buttons.Start))
            {
                if (gamePadState.IsButtonDown(Buttons.A))
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.B))
                {
                    command = new FireBallCommand(Game1.Instance);
                    command.Execute();
                    command = new SprintCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadLeft))
                {
                    command = new LeftCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadRight))
                {
                    command = new RightCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadUp))
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.DPadDown))
                {
                    command = new DownCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X > 0.5f)
                {
                    command = new RightCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X < -0.5f)
                {
                    command = new LeftCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.Y > 0.5f)
                {
                    command = new UpCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.ThumbSticks.Left.X < -0.5f)
                {
                    command = new DownCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.Back))
                {
                    command = new ExitCommand(Game1.Instance);
                    command.Execute();
                }
                if (gamePadState.IsButtonDown(Buttons.Start))
                {
                    command = new SwitchControllerCommand();
                    command.Execute();
                }
                if (!gamePadState.IsButtonDown(Buttons.DPadLeft) && !gamePadState.IsButtonDown(Buttons.DPadRight))
                {
                    command = new IdleMarioCommand(Game1.Instance);
                    command.Execute();
                }
            }
            else
            {
                idleCommand.Execute();
            }
        }
        public static void InitializeControllersForGameplay(Game1 game, KeyboardController keyboard, GamepadController gamepad)
        {
            keyboard.ClearDictionary();
            gamepad.ClearDictionary();
            //Background sound
            ICommand mutecommand = new MuteCommand(Stage.sound);

            keyboard.Add((int)Keys.M, mutecommand);
            //Add the Reset command to the r
            ICommand resetcommand = new ResetCommand();

            keyboard.Add((int)Keys.R, resetcommand);
            gamepad.Add((int)Buttons.Back, resetcommand);
            //Add the Exit Command to the controllers
            ICommand exitcommand = new ExitCommand(game);

            keyboard.Add((int)Keys.Q, exitcommand);
            gamepad.Add((int)Buttons.Start, exitcommand);
            //add the left command
            ICommand leftcommand = new LeftCommand(Stage.mario);

            keyboard.Add((int)Keys.A, leftcommand);
            keyboard.Add((int)Keys.Left, leftcommand);
            gamepad.Add((int)Buttons.DPadLeft, leftcommand);
            //add the right commmand
            ICommand rightcommand = new RightCommand(Stage.mario);

            keyboard.Add((int)Keys.D, rightcommand);
            keyboard.Add((int)Keys.Right, rightcommand);
            gamepad.Add((int)Buttons.DPadRight, rightcommand);
            //Add the srpint command
            ICommand sprintcommand = new SprintCommand(Stage.mario);

            keyboard.Add((int)Keys.LeftShift, sprintcommand);
            keyboard.Add((int)Keys.RightShift, sprintcommand);
            //add the down command
            ICommand downcommand = new DownCommand(Stage.mario);

            keyboard.Add((int)Keys.S, downcommand);
            keyboard.Add((int)Keys.Down, downcommand);
            gamepad.Add((int)Buttons.DPadDown, downcommand);
            //add the up command
            ICommand upcommand = new UpCommand(Stage.mario);

            keyboard.Add((int)Keys.W, upcommand);
            keyboard.Add((int)Keys.Up, upcommand);
            gamepad.Add((int)Buttons.DPadUp, upcommand);
            //add fireflower command
            ICommand firecommand = new FireMarioCommand(Stage.mario);

            keyboard.Add((int)Keys.I, firecommand);
            //add super command
            ICommand supercommand = new SuperCommand(Stage.mario);

            keyboard.Add((int)Keys.U, supercommand);
            //add normal mario command
            ICommand normalcommand = new NormalCommand(Stage.mario);

            keyboard.Add((int)Keys.Y, normalcommand);
            //add take damage command
            ICommand damagecommand = new DamageCommand(Stage.mario);

            keyboard.Add((int)Keys.O, damagecommand);
            //add star power command
            ICommand starcommand = new StarCommand(Stage.mario);

            keyboard.Add((int)Keys.L, starcommand);
            //add the fireball command with space
            ICommand fireballcommand = new MakeFireBall(Stage.mario);

            keyboard.Add((int)Keys.Space, fireballcommand);
            //add the Pause hud command with N
            ICommand pausehudcommand = new PauseCommand();

            keyboard.Add((int)Keys.P, pausehudcommand);
            ICommand interact = new InteractCommand();

            keyboard.Add((int)Keys.V, interact);
            gamepad.Add((int)Buttons.RightTrigger, interact);
            //add hold command E, no current mapping on gamepad
            ICommand holdcommand = new HoldingCommand(Stage.mario);

            keyboard.Add((int)Keys.E, holdcommand);


            /*
             * Add release commands. These are mainly for mario movement.
             */
            ICommand rightR = new ReleaseRightCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.D, rightR);
            keyboard.AddRelease((int)Keys.Right, rightR);


            ICommand leftR = new ReleaseLeftCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.A, leftR);
            keyboard.AddRelease((int)Keys.Left, leftR);

            ICommand downR = new ReleaseDownCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.S, downR);
            keyboard.AddRelease((int)Keys.Down, downR);


            ICommand upR = new ReleaseUpCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.W, upR);
            keyboard.AddRelease((int)Keys.Up, upR);

            ICommand sprintR = new ReleaseSprintCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.LeftShift, sprintR);
            keyboard.AddRelease((int)Keys.RightShift, sprintR);

            ICommand holdR = new ReleaseHoldingCommand(Stage.mario);

            keyboard.AddRelease((int)Keys.E, holdR);
        }