public void Update(GameTime time) { var kbState = Keyboard.GetState(); var isRunning = kbState.IsKeyDown(Keys.LeftShift); // Movement if (kbState.IsKeyDown(Keys.A)) { Props.AddForceX(-acceleration * (isRunning ? runModifier : 1)); } else if (kbState.IsKeyDown(Keys.D)) { Props.AddForceX(acceleration * (isRunning ? runModifier : 1)); } if (kbState.IsKeyDown(Keys.W)) { Props.AddForceY(-acceleration * (isRunning ? runModifier : 1)); } else if (kbState.IsKeyDown(Keys.S)) { Props.AddForceY(acceleration * (isRunning ? runModifier : 1)); } // Anims animCurrent.Update(time.ElapsedGameTime.Milliseconds); // Ensure correct anim is being used if (IsJetPacking) { if (animCurrent.Name != animJetting.Name) { animCurrent = animJetting; } } else if (Props.IsGrounded) { if (Props.Velocity.X != 0 && animCurrent.Name != animWalking.Name) { animCurrent = animWalking; } else if (Props.Velocity.X == 0 && animCurrent.Name != animStanding.Name) { animCurrent = animStanding; } } else { if (animCurrent.Name != animStanding.Name) { animCurrent = animStanding; } } /* * // Jump action * var canJump = (Props.IsGrounded && Props.Velocity.Y == 0); * * if (kbState.IsKeyDown(Keys.Space) && canJump) * { * Props.AddForceY(-jumpPower, overrideTopSpeed: true); * * // raise event * eventBus.QueueNotification(Events.PlayerJumped); * } * * // Jetpack * if (kbState.IsKeyDown(Keys.W)) * { * IsJetPacking = true; * Props.AddForceY(-jetPower, overrideTopSpeed: true); * } * else * { * IsJetPacking = false; * } */ // projectiles fireListener.Update(time); var mouseState = Mouse.GetState(); var mousePos = mouseState.Position; // aim base.Props.Rotation = Bonsai.Framework.Maths.GameMathHelper .GetDirectionInRadians(this.Position, (camera.CurrentFocus - BonsaiGame.Current.ScreenCenter) + new Vector2(mousePos.X, mousePos.Y)); }