public bool UpdateHeldState() { var state = FloatingHoldable.HoldState == FloatingHoldable.HoldStateEnum.Held; if (!state) { _index = FreeplaySelection.Timer; } return(state); }
public IEnumerator HandleInput() { Selectable = FreeplayDevice.GetComponent <Selectable>(); if (!Input.GetKeyDown(KeyCode.LeftArrow) && !Input.GetKeyDown(KeyCode.RightArrow) && !Input.GetKeyDown(KeyCode.UpArrow) && !Input.GetKeyDown(KeyCode.DownArrow) && !Input.GetKeyDown(KeyCode.Return) && !Input.GetKeyDown(KeyCode.KeypadEnter)) { yield break; } if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return)) { StartBomb(); yield break; } if (Input.GetKeyDown(KeyCode.UpArrow)) { _index--; if (_index == FreeplaySelection.Bombs && !MultipleBombs.Installed()) { _index = FreeplaySelection.Timer; } if (_index < FreeplaySelection.Timer) { _index = FreeplaySelection.ModsOnly; } ToggleIndex(); yield break; } if (Input.GetKeyDown(KeyCode.DownArrow)) { _index++; if (_index == FreeplaySelection.Bombs && !MultipleBombs.Installed()) { _index = FreeplaySelection.Modules; } if (_index > FreeplaySelection.ModsOnly) { _index = FreeplaySelection.Timer; } ToggleIndex(); yield break; } if (!Input.GetKeyDown(KeyCode.LeftArrow) && !Input.GetKeyDown(KeyCode.RightArrow)) { yield break; } IEnumerator handler = null; switch (_index) { case FreeplaySelection.Timer: SelectObject(Input.GetKeyDown(KeyCode.LeftArrow) ? FreeplayDevice.TimeDecrement : FreeplayDevice.TimeIncrement); break; case FreeplaySelection.Bombs: SelectObject(Input.GetKeyDown(KeyCode.LeftArrow) ? _bombsDecrementButton : _bombsIncrementButton); break; case FreeplaySelection.Modules: SelectObject(Input.GetKeyDown(KeyCode.LeftArrow) ? FreeplayDevice.ModuleCountDecrement : FreeplayDevice.ModuleCountIncrement); break; case FreeplaySelection.Needy: handler = SetNeedy(); break; case FreeplaySelection.Hardcore: handler = SetHardcore(); break; case FreeplaySelection.ModsOnly: handler = SetModsOnly(); break; default: throw new ArgumentOutOfRangeException(); } if (handler == null) { yield break; } while (handler.MoveNext()) { yield return(handler.Current); } }
public void ToggleIndex() { var currentSettings = FreeplayDevice.CurrentSettings; var currentModuleCount = currentSettings.ModuleCount; var currentBombsCount = MultipleBombs.GetBombCount(); var currentTime = currentSettings.Time; var onlyMods = currentSettings.OnlyMods; switch (_index) { case FreeplaySelection.Timer: try { SelectObject(FreeplayDevice.TimeIncrement); if (Mathf.FloorToInt(currentTime) == Mathf.FloorToInt(currentSettings.Time)) { break; } SelectObject(FreeplayDevice.TimeDecrement); } catch (Exception ex) { DebugLog("Failed to Select the Timer buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; case FreeplaySelection.Bombs: try { if (!MultipleBombs.Installed()) { break; } SelectObject(_bombsIncrementButton); if (currentBombsCount == MultipleBombs.GetBombCount()) { break; } SelectObject(_bombsDecrementButton); } catch (Exception ex) { DebugLog("Failed to Select the Bomb count buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; case FreeplaySelection.Modules: try { SelectObject(FreeplayDevice.ModuleCountIncrement); if (currentModuleCount == currentSettings.ModuleCount) { break; } SelectObject(FreeplayDevice.ModuleCountDecrement); } catch (Exception ex) { DebugLog("Failed to Select the Module count buttons due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; case FreeplaySelection.Needy: try { SelectObject(FreeplayDevice.NeedyToggle); SelectObject(FreeplayDevice.NeedyToggle); } catch (Exception ex) { DebugLog("Failed to Select the Needy toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; case FreeplaySelection.Hardcore: try { SelectObject(FreeplayDevice.HardcoreToggle); SelectObject(FreeplayDevice.HardcoreToggle); } catch (Exception ex) { DebugLog("Failed to Select the Hardcore toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; case FreeplaySelection.ModsOnly: try { SelectObject(FreeplayDevice.ModsOnly); var onlyModsCurrent = currentSettings.OnlyMods; SelectObject(FreeplayDevice.ModsOnly); if (onlyMods == onlyModsCurrent) { if (Input.GetKey(KeyCode.DownArrow)) { _index = FreeplaySelection.Timer; goto case FreeplaySelection.Timer; } else { _index = FreeplaySelection.Hardcore; goto case FreeplaySelection.Hardcore; } } } catch (Exception ex) { DebugLog("Failed to Select the Mods only toggle due to Exception: {0}, Stack Trace: {1}", ex.Message, ex.StackTrace); } break; default: throw new ArgumentOutOfRangeException(); } }