private void SetupController() { UserInput = new UserInputController(); UserInput.RegisterKeyPressAction(Keys.D, (Vector2 thumbStickPosition) => { VelocityX += MovementSpeed * Globals.FixedUpdateMultiplier * Config.TIME_OFFSET; }); UserInput.RegisterKeyPressAction(Keys.A, Buttons.LeftThumbstickLeft, (Vector2 thumbStickPosition) => { VelocityX -= MovementSpeed * Globals.FixedUpdateMultiplier * Config.TIME_OFFSET; }); UserInput.RegisterKeyPressAction(Keys.W, (Vector2 thumbStickPosition) => { if (jumpCount < 2 && currentJump < MAX_JUMP) { VelocityY -= JUMP_FORCE; currentJump += JUMP_FORCE; VelocityY -= JUMP_FORCE; FallSpeed = 0; AudioEngine.Play("HeroJump", true); //jumpCount++; } }); UserInput.RegisterKeyReleaseAction(Keys.W, () => { //if (jumpCount < 2) { currentJump = 0; jumpCount++; } if (IsOnGround) { //jumpCount = 0; } }); UserInput.LeftClickPressedAction = (mousePosition) => { if (CurrentWeapon != null && !CurrentWeapon.IsEmpty() && !IsKicking) { CurrentWeapon.TriggerPulled(Scene.Camera.ScreenToWorldSpace(mousePosition)); } }; UserInput.LeftClickUpAction = (mousePosition) => { if (CurrentWeapon != null && !CurrentWeapon.IsEmpty() && !IsKicking) { CurrentWeapon.TriggerReleased(Scene.Camera.ScreenToWorldSpace(mousePosition)); } }; UserInput.RightClickDownAction = (mousePosition) => { if (CurrentFaceDirection == Direction.WEST) { if (flying) { GetComponent <AnimationStateMachine>().PlayAnimation("KickJetpackLeft"); } else { GetComponent <AnimationStateMachine>().PlayAnimation("KickLeft"); } } else { if (flying) { GetComponent <AnimationStateMachine>().PlayAnimation("KickJetpackRight"); } else { GetComponent <AnimationStateMachine>().PlayAnimation("KickRight"); } } }; /*UserInput.RegisterKeyPressAction(Keys.Down, Buttons.LeftThumbstickLeft, (Vector2 thumbStickPosition) => * { * VelocityY += MovementSpeed * Globals.FixedUpdateMultiplier * Config.TIME_OFFSET; * });*/ UserInput.RegisterKeyPressAction(Keys.Space, (Vector2 thumbStickPosition) => { if (Fuel > 0) { //AudioEngine.Play("Jetpack"); VelocityY -= JETPACK_SPEED; Fuel -= JETPACK_SPEED; flying = true; if (Fuel < 0) { Fuel = 0; } } else { flying = false; } }); UserInput.RegisterKeyReleaseAction(Keys.Space, () => { flying = false; //AudioEngine.Stop("Jetpack"); }); UserInput.RegisterMouseActions( () => { NextWeapon(); /*Timer.Repeat(300, (elapsedTime) => * { * Scene.Camera.Zoom += 0.002f * elapsedTime; * });*/ }, () => { PreviousWeapon(); /*Timer.Repeat(300, (elapsedTime) => * { * Scene.Camera.Zoom -= 0.002f * elapsedTime; * });*/ } , 100); /*UserInput.RegisterKeyPressAction(Keys.Space, (Vector2 thumbStickPosition) => * { * if (CurrentWeapon != null && !CurrentWeapon.IsEmpty()) * { * CurrentWeapon.TriggerPulled(); * } * * }); * * UserInput.RegisterKeyReleaseAction(Keys.Space, () => * { * if (CurrentWeapon != null && !CurrentWeapon.IsEmpty()) * { * CurrentWeapon.TriggerReleased(); * } * * });*/ UserInput.RegisterKeyPressAction(Keys.D1, (Vector2 thumbStickPosition) => { CurrentWeapon?.Destroy(); CurrentWeapon = new Handgun(Scene, this); }, true); UserInput.RegisterKeyPressAction(Keys.D2, (Vector2 thumbStickPosition) => { CurrentWeapon?.Destroy(); CurrentWeapon = new Machinegun(Scene, this); }, true); UserInput.RegisterKeyPressAction(Keys.D3, (Vector2 thumbStickPosition) => { CurrentWeapon?.Destroy(); CurrentWeapon = new Shotgun(Scene, this); }, true); UserInput.MouseMovedAction = (prevMousePos, currentMousePos) => { Vector2 worldPos = Scene.Camera.ScreenToWorldSpace(currentMousePos); if (Transform.Position.X < worldPos.X) { if (!IsKicking) { CurrentFaceDirection = Direction.EAST; } } else { if (!IsKicking) { CurrentFaceDirection = Direction.WEST; } } CurrentWeapon?.SetDirection(CurrentFaceDirection); CurrentWeapon?.FollowMouse(worldPos); }; /*UserInput.RegisterKeyPressAction(Keys.Escape, (Vector2 thumbstickPosition) => * { * Config.ExitAction.Invoke(); * });*/ }