private bool ShouldThumbstickScroll(float axisValue, float threshold, Func <float, float, bool> scrollFunc, ref AxisScrollState scrollState) { bool shouldScroll = false; LetterInputManager letterInputManager; if (LetterInputManager.TryGetInstance(out letterInputManager)) { switch (scrollState) { case AxisScrollState.Idle: if (scrollFunc(axisValue, threshold)) { shouldScroll = true; scrollState = AxisScrollState.SingleScroll; currentTimeToScroll = 0f; } break; case AxisScrollState.SingleScroll: if (scrollFunc(axisValue, threshold)) { currentTimeToScroll += Time.deltaTime; if (currentTimeToScroll > letterInputManager.timeToScroll) { shouldScroll = true; currentScrollTime = 0f; scrollState = AxisScrollState.Scrolling; } } else { scrollState = AxisScrollState.Idle; } break; case AxisScrollState.Scrolling: if (scrollFunc(axisValue, threshold)) { currentScrollTime += Time.deltaTime; if (currentScrollTime > letterInputManager.scrollSpeed) { currentScrollTime -= letterInputManager.scrollSpeed; shouldScroll = true; } } else { scrollState = AxisScrollState.Idle; currentScrollTime = 0f; currentTimeToScroll = 0f; } break; } } return(shouldScroll); }
// Update is called once per frame void Update() { if (isActive) { LetterInputManager letterInputManager; if (LetterInputManager.TryGetInstance(out letterInputManager)) { if (player.GetButtonDown("DPadUp") || ShouldThumbstickScroll(player.GetAxis("Left Leg Vertical"), letterInputManager.GetThumbstickScrollDeadzone(), GreaterThan, ref positiveScrollState)) { ModifyLetter(-1); } else if (player.GetButtonDown("DPadDown") || ShouldThumbstickScroll(player.GetAxis("Left Leg Vertical"), -letterInputManager.GetThumbstickScrollDeadzone(), LessThan, ref negativeScrollState)) { ModifyLetter(1); } } } }
private void EnterScore() { waitingForInvoke = false; LetterInputManager letterInputManager; if (LetterInputManager.TryGetInstance(out letterInputManager)) { letterInputManager.gameObject.SetActive(true); letterInputManager.ShowLetterInput(currentTime); } GameManager gameManager; if (GameManager.TryGetInstance(out gameManager)) { gameManager.OnEnterScore(); } gameState = GameState.EnteringHighScore; ResetGame(); currentTime = 0f; currentIntegrity = maxIntegrity / 2; }
private void Awake() { instance = this; }
public static bool TryGetInstance(out LetterInputManager manager) { manager = instance; return(manager != null); }