public void Update() { gamepadState = GamePad.GetState(PlayerIndex.One); KeyboardState keyState = Keyboard.GetState(); commands = new List <ICommands>(); if (gamepadState.DPad.Down.Equals(ButtonState.Pressed)) { commands.Add(new DownCommand(mario)); } if (gamepadState.DPad.Left.Equals(ButtonState.Pressed)) { commands.Add(new LeftCommand(mario)); } if (gamepadState.DPad.Right.Equals(ButtonState.Pressed)) { commands.Add(new RightCommand(mario)); } if (gamepadState.Buttons.A.Equals(ButtonState.Pressed)) { commands.Add(new UpCommand(mario)); } if (gamepadState.Buttons.X.Equals(ButtonState.Pressed)) { commands.Add(new RunCommand(mario)); } if (gamepadState.Buttons.Back == ButtonState.Pressed) { commands.Add(new ResetSceneCommand()); } if (gamepadState.Buttons.Start == ButtonState.Pressed) { commands.Add(new PauseCommand()); } if (gamepadState.Buttons.B.Equals(ButtonState.Pressed)) { commands.Add(new ProjectileCommand(mario)); } if (gamepadState.Buttons.LeftShoulder.Equals(ButtonState.Pressed)) { commands.Add(new QuitCommand()); } foreach (ICommands command in commands) { command.Execute(); } mario.Idle(); }
public void Update() { currentCommand = new NullCommand(); GamePadState gamepadState = GamePad.GetState(PlayerIndex.One); keyboardState = Keyboard.GetState(); foreach (Keys key in keyboardState.GetPressedKeys()) { if (commandLibrary.ContainsKey(key)) { currentCommand = commandLibrary[key]; currentCommand.Execute(); } } mario.Idle(); }
public void Execute() { mario.Idle(); }