public void UnregisterDevice(Device d) { if (_registeredDevices.Contains(d)) { _registeredDevices.Remove(d); } }
public void RegisterDevice(Device d) { _registeredDevices.Add(d); }
/// <summary> /// Manage input for player for a given device /// </summary> /// <param name="gameTime"></param> /// <param name="device"></param> private void GetInput(GameTime gameTime, Device device) { if (_isNotVisible) return; if (_isReading) { if ((device.GetState(MappingButtons.A).IsReleased) || (device.GetState(MappingButtons.X).IsReleased) || (device.GetState(MappingButtons.Y).IsPressed)) { Application.ScriptManager.SetFlag(LapinsScript.TextToDisplay, ""); } } else { // Move left & right float leftright = device.ThumbStickLeft.X; if (leftright < -0.3f || leftright > 0.3f) { velocity.X += ((_boxlife > 0) ? 25f : 50f) * leftright; _inputDetected = true; if (IsStuckLeft && velocity.X < 0) velocity.X = 0f; if (IsStuckRight && velocity.X > 0) velocity.X = 0f; } if (device.GetState(MappingButtons.Y).IsPressed) { _pressedAction = true; } if (device.GetState(MappingButtons.X).IsDown) { _isRunning = false; } // Jump if (device.GetState(MappingButtons.A).IsDown) { if (IsOnGround && !_wasJumping) // take off the ground { _isJumping = true; _currentJump++; if (_currentJump > MaxJumpAllowed) _currentJump = 1; _bunnyJumpTime = 0; // Add if (MovingFloorMovement != Vector2.Zero) { if ((velocity.X < 0) && (MovingFloorMovement.X < 0) || (velocity.X > 0) && (MovingFloorMovement.X > 0)) { _bonusSpeed.X = Math.Abs(MovingFloorMovement.X); } if ((velocity.Y < 0) && (MovingFloorMovement.Y < 0) || (velocity.Y > 0) && (MovingFloorMovement.Y > 0)) { _bonusSpeed.Y = Math.Abs(MovingFloorMovement.Y); } _bonusSpeed *= 100; } } else { _isJumping = true; } } } }