void ProcessInput(TimeSpan delta) { input.Update(); if (!ui.KeyboardGrabbed) { if (input.ActionDown(InputAction.ID_THROTTLEUP)) { shipInput.Throttle += (float)(delta.TotalSeconds); shipInput.Throttle = MathHelper.Clamp(shipInput.Throttle, 0, 1); } else if (input.ActionDown(InputAction.ID_THROTTLEDOWN)) { shipInput.Throttle -= (float)(delta.TotalSeconds); shipInput.Throttle = MathHelper.Clamp(shipInput.Throttle, 0, 1); } } StrafeControls strafe = StrafeControls.None; if (!ui.KeyboardGrabbed) { if (input.ActionDown(InputAction.ID_STRAFELEFT)) { strafe |= StrafeControls.Left; } if (input.ActionDown(InputAction.ID_STRAFERIGHT)) { strafe |= StrafeControls.Right; } if (input.ActionDown(InputAction.ID_STRAFEUP)) { strafe |= StrafeControls.Up; } if (input.ActionDown(InputAction.ID_STRAFEDOWN)) { strafe |= StrafeControls.Down; } } var pc = player.PhysicsComponent; shipInput.Viewport = new Vector2(Game.Width, Game.Height); shipInput.Camera = camera; if (Game.Mouse.IsButtonDown(MouseButtons.Left) || mouseFlight) { var mX = Game.Mouse.X; var mY = Game.Mouse.Y; camera.MousePosition = new Vector2( mX, Game.Height - mY ); shipInput.MouseFlight = true; shipInput.MousePosition = new Vector2(mX, mY); camera.MouseFlight = true; } else { shipInput.MouseFlight = false; camera.MouseFlight = false; } control.CurrentStrafe = strafe; //control.EnginePower = Velocity / MAX_VELOCITY; var obj = GetSelection(Game.Mouse.X, Game.Mouse.Y); current_cur = obj == null ? cur_arrow : cur_reticle; var ep = Vector3Ex.UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 0.25f), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var tgt = Vector3Ex.UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 0f), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var dir = (tgt - ep).Normalized(); weapons.AimPoint = tgt; if (!Game.Mouse.IsButtonDown(MouseButtons.Left) && Game.TotalTime - lastDown < 0.25) { var newselected = GetSelection(Game.Mouse.X, Game.Mouse.Y); if (newselected != null) { selected = newselected; } } if (Game.Mouse.IsButtonDown(MouseButtons.Right)) { weapons.FireAll(); } }
void ProcessInput(double delta) { if (paused) { return; } input.Update(); if (!ui.KeyboardGrabbed) { if (input.ActionDown(InputAction.ID_THROTTLEUP)) { shipInput.Throttle += (float)(delta); shipInput.Throttle = MathHelper.Clamp(shipInput.Throttle, 0, 1); } else if (input.ActionDown(InputAction.ID_THROTTLEDOWN)) { shipInput.Throttle -= (float)(delta); shipInput.Throttle = MathHelper.Clamp(shipInput.Throttle, 0, 1); } } StrafeControls strafe = StrafeControls.None; if (!ui.KeyboardGrabbed) { if (input.ActionDown(InputAction.ID_STRAFELEFT)) { strafe |= StrafeControls.Left; } if (input.ActionDown(InputAction.ID_STRAFERIGHT)) { strafe |= StrafeControls.Right; } if (input.ActionDown(InputAction.ID_STRAFEUP)) { strafe |= StrafeControls.Up; } if (input.ActionDown(InputAction.ID_STRAFEDOWN)) { strafe |= StrafeControls.Down; } } var pc = player.PhysicsComponent; shipInput.Viewport = new Vector2(Game.Width, Game.Height); shipInput.Camera = camera; if (isLeftDown || mouseFlight) { var mX = Game.Mouse.X; var mY = Game.Mouse.Y; camera.MousePosition = new Vector2( mX, Game.Height - mY ); shipInput.MouseFlight = true; shipInput.MousePosition = new Vector2(mX, mY); camera.MouseFlight = true; } else { shipInput.MouseFlight = false; camera.MouseFlight = false; } control.CurrentStrafe = strafe; var obj = GetSelection(Game.Mouse.X, Game.Mouse.Y); if (ui.MouseWanted(Game.Mouse.X, Game.Mouse.Y)) { current_cur = cur_arrow; } else { current_cur = obj == null ? cur_cross : cur_reticle; } var end = Vector3Ex.UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 1f), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var start = Vector3Ex.UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 0), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var dir = (end - start).Normalized(); var tgt = start + (dir * 400); weapons.AimPoint = tgt; if (world.Physics.PointRaycast(player.PhysicsComponent.Body, start, dir, 1000, out var contactPoint, out var po)) { weapons.AimPoint = contactPoint; } if (Game.Mouse.IsButtonDown(MouseButtons.Right)) { weapons.FireAll(); } if (world.Projectiles.HasQueued) { session.RpcServer.FireProjectiles(world.Projectiles.GetQueue()); } }
void ProcessInput(TimeSpan delta) { moffset = (new Vector2(Game.Mouse.X, Game.Mouse.Y) - new Vector2(Game.Width / 2, Game.Height / 2)); moffset *= new Vector2(1f / Game.Width, 1f / Game.Height); moffset *= 2; input.Update(); if (!hud.TextEntry) { if (input.ActionDown(InputAction.ID_THROTTLEUP)) { control.EnginePower += (float)(delta.TotalSeconds); control.EnginePower = MathHelper.Clamp(control.EnginePower, 0, 1); } else if (input.ActionDown(InputAction.ID_THROTTLEDOWN)) { control.EnginePower -= (float)(delta.TotalSeconds); control.EnginePower = MathHelper.Clamp(control.EnginePower, 0, 1); } } StrafeControls strafe = StrafeControls.None; if (!hud.TextEntry) { if (input.ActionDown(InputAction.ID_STRAFELEFT)) { strafe |= StrafeControls.Left; } if (input.ActionDown(InputAction.ID_STRAFERIGHT)) { strafe |= StrafeControls.Right; } if (input.ActionDown(InputAction.ID_STRAFEUP)) { strafe |= StrafeControls.Up; } if (input.ActionDown(InputAction.ID_STRAFEDOWN)) { strafe |= StrafeControls.Down; } } var pc = player.PhysicsComponent; if (Game.Mouse.IsButtonDown(MouseButtons.Left) || mouseFlight) { control.PlayerPitch = -moffset.Y; control.PlayerYaw = -moffset.X; var mX = Game.Mouse.X; var mY = Game.Mouse.Y; camera.MousePosition = new Vector2( mX, Game.Height - mY ); camera.MouseFlight = true; } else { control.PlayerPitch = control.PlayerYaw = 0; camera.MouseFlight = false; } control.CurrentStrafe = strafe; //control.EnginePower = Velocity / MAX_VELOCITY; var obj = GetSelection(Game.Mouse.X, Game.Mouse.Y); current_cur = obj == null ? cur_arrow : cur_reticle; var ep = UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 0.25f), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var tgt = UnProject(new Vector3(Game.Mouse.X, Game.Mouse.Y, 0f), camera.Projection, camera.View, new Vector2(Game.Width, Game.Height)); var dir = (tgt - ep).Normalized(); var dir2 = new Matrix3(player.PhysicsComponent.Body.Transform.ClearTranslation()) * Vector3.UnitZ; tgt += dir * 750; weapons.AimPoint = tgt; if (!Game.Mouse.IsButtonDown(MouseButtons.Left) && Game.TotalTime - lastDown < 0.25) { var newselected = GetSelection(Game.Mouse.X, Game.Mouse.Y); if (newselected != null) { selected = newselected; } } if (Game.Mouse.IsButtonDown(MouseButtons.Right)) { weapons.FireAll(); } }