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(); } }
public void ToggleIndex() { object currentSettings = _currentSettingsField.GetValue(FreeplayDevice, null); int currentModuleCount = (int)_moduleCountField.GetValue(currentSettings); int currentBombsCount = MultipleBombs.GetBombCount(); float currentTime = (float)_timeField.GetValue(currentSettings); bool onlyMods = (bool)_onlyModsField.GetValue(currentSettings); switch (_index) { case freeplaySelection.Timer: try { MonoBehaviour timerUp = (MonoBehaviour)_timeIncrementField.GetValue(FreeplayDevice); MonoBehaviour timerDown = (MonoBehaviour)_timeDecrementField.GetValue(FreeplayDevice); SelectObject((MonoBehaviour)timerUp.GetComponent(_selectableType)); if (Mathf.FloorToInt(currentTime) == Mathf.FloorToInt((float)_timeField.GetValue(currentSettings))) { break; } SelectObject((MonoBehaviour)timerDown.GetComponent(_selectableType)); } 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; } MonoBehaviour bombsUp = SelectableChildren[3]; MonoBehaviour bombsDown = SelectableChildren[2]; SelectObject(bombsUp); if (currentBombsCount == MultipleBombs.GetBombCount()) { break; } SelectObject(bombsDown); } 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 { MonoBehaviour moduleUp = (MonoBehaviour)_moduleCountIncrementField.GetValue(FreeplayDevice); MonoBehaviour moduleDown = (MonoBehaviour)_moduleCountDecrementField.GetValue(FreeplayDevice); SelectObject((MonoBehaviour)moduleUp.GetComponent(_selectableType)); if (currentModuleCount == (int)_moduleCountField.GetValue(currentSettings)) { break; } SelectObject((MonoBehaviour)moduleDown.GetComponent(_selectableType)); } 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 { MonoBehaviour needyToggle = (MonoBehaviour)_needyToggleField.GetValue(FreeplayDevice); SelectObject((MonoBehaviour)needyToggle.GetComponent(_selectableType)); SelectObject((MonoBehaviour)needyToggle.GetComponent(_selectableType)); } 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 { MonoBehaviour hardcoreToggle = (MonoBehaviour)_hardcoreToggleField.GetValue(FreeplayDevice); SelectObject((MonoBehaviour)hardcoreToggle.GetComponent(_selectableType)); SelectObject((MonoBehaviour)hardcoreToggle.GetComponent(_selectableType)); } 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 { MonoBehaviour modsToggle = (MonoBehaviour)_modsOnlyToggleField.GetValue(FreeplayDevice); SelectObject((MonoBehaviour)modsToggle.GetComponent(_selectableType)); bool onlyModsCurrent = (bool)_onlyModsField.GetValue(currentSettings); SelectObject((MonoBehaviour)modsToggle.GetComponent(_selectableType)); 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; } }