public void Update(GameTime gameTime, Vector2 locationOffset) { PreviousState = CurrentState; CurrentState = Mouse.GetState(); LeftButtonIsPressed = PreviousState.LeftButton == ButtonState.Pressed && CurrentState.LeftButton == ButtonState.Released; RightButtonIsPressed = PreviousState.RightButton == ButtonState.Pressed && CurrentState.RightButton == ButtonState.Released; PreviousLocation = Location + locationOffset; Location = new Vector2(CurrentState.X + locationOffset.X, CurrentState.Y + locationOffset.Y); if (AutoHide) { if ((PreviousLocation == Location) && ((CurrentState.LeftButton != ButtonState.Pressed) && (CurrentState.RightButton != ButtonState.Pressed))) { AutoHideTimer.Update(gameTime); if (AutoHideTimer.IsDone) { IsAutoHidden = true; } } else { AutoHideTimer.Reset(); IsAutoHidden = false; } } }
public void Update(GameTime gameTime) { if (IsFlashing) { Timer.Update(gameTime); if (Timer.IsDone) { DrawThisCycle = !DrawThisCycle; Timer.Reset(); } } }
public void Update(GameTime gameTime) { if (!IsDone) { IsInterval = false; Timer.Update(gameTime); if (Timer.IsDone) // Check if interval time elapsed. { IsInterval = true; TotalMS -= IntervalMS; // Check if done if (TotalMS <= 0) { IsDone = true; } else { Timer.Reset(); } } } }
public void Update(GameTime gameTime) { DrawBoxTimer.Update(gameTime); }
public virtual void Update(GameTime gameTime) { #region Scroll down & up if (InputMgr.Instance.IsPressed(null, Keys.Down, Buttons.DPadDown) || InputMgr.Instance.IsPressed(Buttons.LeftThumbstickDown) || InputMgr.Instance.IsPressed(Buttons.RightThumbstickDown)) { SelectedIdx++; } if (InputMgr.Instance.IsPressed(null, Keys.Up, Buttons.DPadUp) || InputMgr.Instance.IsPressed(Buttons.LeftThumbstickUp) || InputMgr.Instance.IsPressed(Buttons.RightThumbstickUp)) { SelectedIdx--; } #endregion #region Auto scroll down & up if (InputMgr.Instance.IsDown(null, Keys.Down, Buttons.DPadDown) || InputMgr.Instance.IsDown(Buttons.LeftThumbstickDown) || InputMgr.Instance.IsDown(Buttons.RightThumbstickDown)) { AutoScrollDelayTimerDown.Update(gameTime); if (AutoScrollDelayTimerDown.IsDone) { AutoScrollDelayTimerDown.Reset(); SelectedIdx++; } } else { AutoScrollDelayTimerDown.Reset(); } if (InputMgr.Instance.IsDown(null, Keys.Up, Buttons.DPadUp) || InputMgr.Instance.IsDown(Buttons.LeftThumbstickUp) || InputMgr.Instance.IsDown(Buttons.RightThumbstickUp)) { AutoScrollDelayTimerUp.Update(gameTime); if (AutoScrollDelayTimerUp.IsDone) { AutoScrollDelayTimerUp.Reset(); SelectedIdx--; } } else { AutoScrollDelayTimerUp.Reset(); } #endregion #region Change choice value if applicable if (InputMgr.Instance.IsPressed(null, Keys.Left, Buttons.DPadLeft) || InputMgr.Instance.IsPressed(Buttons.LeftThumbstickLeft) || InputMgr.Instance.IsPressed(Buttons.RightThumbstickLeft)) { if (ActiveChoice.Values.Count > 0) { if (ActiveChoice.SetSelectedIdx(ActiveChoice.SelectedValueIdx - 1)) { if (ValueChanged != null) { ValueChanged(ActiveChoice, ActiveChoice.Values[ActiveChoice.SelectedValueIdx + 1], ActiveChoice.SelectedValue); } } } } if (InputMgr.Instance.IsPressed(null, Keys.Right, Buttons.DPadRight) || InputMgr.Instance.IsPressed(Buttons.LeftThumbstickRight) || InputMgr.Instance.IsPressed(Buttons.RightThumbstickRight)) { if (ActiveChoice.Values.Count > 0) { if (ActiveChoice.SetSelectedIdx(ActiveChoice.SelectedValueIdx + 1)) { if (ValueChanged != null) { ValueChanged(ActiveChoice, ActiveChoice.Values[ActiveChoice.SelectedValueIdx - 1], ActiveChoice.SelectedValue); } } } } #endregion #region Select choice bool choiceWasSelected = false; // using 'selector' if (InputMgr.Instance.IsPressed(null, InputMgr.Instance.DefaultConfirmKey, InputMgr.Instance.DefaultConfirmButton)) { if (SelectChoice != null) { SelectChoice(ActiveChoice); choiceWasSelected = true; } } // using index if (AllowToSelectByIdx && !choiceWasSelected) { List <Keys> keysPressed = InputMgr.Instance.Keyboard.GetAllReleasedKeys(); foreach (Keys k in keysPressed) { if (k >= Keys.D0 && k <= Keys.D9) { SelectChoice(Choices[int.Parse(k.ToString().Substring(1, 1)) - 1]); break; } } } #endregion }