public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); if (Target == null) return; switch (Mode) { case MovementMode.XYZ: #region XYZ Vector3 vectorToAdd = Vector3.Zero; if (inputHelper.IsKeyDown(Keys.W)) vectorToAdd -= Vector3.UnitZ; if (inputHelper.IsKeyDown(Keys.S)) vectorToAdd += Vector3.UnitZ; if (inputHelper.IsKeyDown(Keys.D)) vectorToAdd += Vector3.UnitX; if (inputHelper.IsKeyDown(Keys.A)) vectorToAdd -= Vector3.UnitX; if (inputHelper.IsKeyDown(Keys.Q)) vectorToAdd -= Vector3.UnitY; if (inputHelper.IsKeyDown(Keys.E)) vectorToAdd += Vector3.UnitY; if (inputHelper.IsKeyDown(Keys.R)) position = Vector3.Zero; if (inputHelper.IsKeyDown(Keys.D1)) Speed /= 1.25f; if (inputHelper.IsKeyDown(Keys.D2)) Speed *= 1.25f; inputHelper.AddMouseRotation(RotationSpeed * updateTime, ref rotation); Matrix cameraRotation = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y); Vector3 rotatedVector = Vector3.Transform(vectorToAdd * Speed * updateTime, cameraRotation); position += rotatedVector; #endregion XYZ break; case MovementMode.XZ: break; default: break; } }
public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); if (obj == null) { Vector3 vectorToAdd = Vector3.Zero; if (inputHelper.IsKeyDown(Keys.W)) vectorToAdd -= Vector3.UnitZ; if (inputHelper.IsKeyDown(Keys.S)) vectorToAdd += Vector3.UnitZ; if (inputHelper.IsKeyDown(Keys.D)) vectorToAdd += Vector3.UnitX; if (inputHelper.IsKeyDown(Keys.A)) vectorToAdd -= Vector3.UnitX; if (inputHelper.IsKeyDown(Keys.Q)) vectorToAdd -= Vector3.UnitY; if (inputHelper.IsKeyDown(Keys.E)) vectorToAdd += Vector3.UnitY; if (inputHelper.IsKeyDown(Keys.R)) position = Vector3.Zero; if (inputHelper.IsKeyDown(Keys.D1)) walkSpeed /= 1.25f; if (inputHelper.IsKeyDown(Keys.D2)) walkSpeed *= 1.25f; inputHelper.AddMouseRotation(rotSpeed, ref rotation); Matrix cameraRotation = Matrix.CreateRotationX(rotation.X) * Matrix.CreateRotationY(rotation.Y); Vector3 rotatedVector = Vector3.Transform(vectorToAdd * walkSpeed, cameraRotation); position += rotatedVector; } }