public void Update(float deltaTime) { MouseState mouseState = Mouse.GetState(); if (pointSelector.SelectedWaypoint != null) { // Move point. if (mouseState.LeftButton == ButtonState.Pressed && pointSelector.MouseIsOverAWayPoint(out _)) { haveSelectedPoint = true; pointSelector.Enabled = false; } if (haveSelectedPoint && mouseState.LeftButton == ButtonState.Released) { pointSelector.Enabled = true; haveSelectedPoint = false; } if (haveSelectedPoint) { pointSelector.SelectedWaypoint.Position -= (oldMousePos - mouseState.Position).ToVector2() / camera.Scale.X; } // Delete point. if (Keyboard.GetState().IsKeyDown(Keys.Delete)) { WaypointManager.WayPoints.Remove(pointSelector.SelectedWaypoint); } // Deselect point. if (Keyboard.GetState().IsKeyDown(Keys.Escape) || Keyboard.GetState().IsKeyDown(Keys.Delete)) { pointSelector.SelectedWaypoint = null; } } else { pointSelector.Enabled = true; } oldMousePos = mouseState.Position; }
public void Update(float deltaTime) { MouseState mouseState = Mouse.GetState(); if ((mouseState.LeftButton == ButtonState.Pressed && lastMouse.LeftButton == ButtonState.Released) && !pointSelector.MouseIsOverAWayPoint(out _)) { WaypointManager.AddPoint(camera.ScreenToWorldPoint(mouseState.Position.ToVector2())); } lastMouse = mouseState; }