public override void Update(GameTime gameTime) { _mousePosition = GMouse.GetState().Position; _itemSelected = false; for (var i = 0; i < _items.Count; i++) { if (_items[i].Rect.Contains(_mousePosition)) { SelectedItemIndex = i; _itemSelected = true; } } if (GKeyboard.IsKeyPressed(Keys.Up)) { SelectedItemIndex -= 1; } if (GKeyboard.IsKeyPressed(Keys.Down)) { SelectedItemIndex += 1; } if (SelectedItem.Action != null && SelectedItem.Type == ActionType.Update && (GKeyboard.IsKeyPressed(Keys.Enter) || (Mouse.GetState().LeftButton == ButtonState.Pressed && _itemSelected))) { Invoke(); } }
public (float Distance, float Angle) GetMousePositionParams() { var mouseState = GMouse.GetState(); var distance = (Vector2.Distance(Center, mouseState.Position.ToVector2()) / ((Size.X + Size.Y) / 2) * 2); var mouseVector = mouseState.Position.ToVector2(); var angle = (float)(-Math.Atan2(mouseVector.Y - Center.Y, mouseVector.X - Center.X) / Math.PI * 180); return(distance, GDartsSegment.NormalizeAngle(angle, AngleNormalizationFactor.AllowNegative)); }