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)); }
protected override void Update(GameTime gameTime) { try { GKeyboard.UpdateState(); GMouse.UpdateState(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || GKeyboard.IsKeyDown(Keys.Escape)) { Exit(); } if (GKeyboard.IsKeyPressed(Keys.A)) { if (GMouse.AlkashCursor) { GMouse.AlkashCursor = false; } else { GMouse.AlkashCursor = true; } } SceneManager.ActiveScene.Update(gameTime); foreach (var ctrl in Controls) { ctrl.Update(gameTime); } base.Update(gameTime); } catch (Exception ex) { Console.WriteLine($"Update method exception:\n{ex.Message}"); } }
public override void Update(GameTime gameTime) { if (GMouse.IsButtonPressed(MouseButton.Left)) { if (Client.ReceiverGameData.WinPlayer != null) { Thread.Sleep(400); TcpAsyncServer.SafeCloseAllSockets(); Game.SceneManager.ActiveState = GameState.MainMenu; foreach (var label in PlayerLabels) { label.Clear(); } } SendShootData(); } foreach (var label in PlayerLabels) { label.Update(gameTime); } }