public FreeplayCommander(FreeplayDevice freeplayDevice) { FreeplayDevice = freeplayDevice; Selectable = FreeplayDevice.GetComponent <Selectable>(); FloatingHoldable = FreeplayDevice.GetComponent <FloatingHoldable>(); _selectableManager = KTInputManager.Instance.SelectableManager; _originalTimeIncrementHandler = FreeplayDevice.TimeIncrement.OnPush; _originalTimeDecrementHandler = FreeplayDevice.TimeDecrement.OnPush; _originalModuleIncrementHandler = FreeplayDevice.ModuleCountIncrement.OnPush; _originalModuleDecrementHandler = FreeplayDevice.ModuleCountDecrement.OnPush; FreeplayDevice.TimeIncrement.OnPush = () => { FreeplayDevice.StartCoroutine(IncrementBombTimer()); }; FreeplayDevice.TimeDecrement.OnPush = () => { FreeplayDevice.StartCoroutine(DecrementBombTimer()); }; FreeplayDevice.ModuleCountIncrement.OnPush = () => { FreeplayDevice.StartCoroutine(IncrementModuleCount()); }; FreeplayDevice.ModuleCountDecrement.OnPush = () => { FreeplayDevice.StartCoroutine(DecrementModuleCount()); }; if (!MultipleBombs.Installed()) { return; } _bombsIncrementButton = Selectable.Children[3].GetComponent <KeypadButton>(); _bombsDecrementButton = Selectable.Children[2].GetComponent <KeypadButton>(); _originalBombIncrementHandler = _bombsIncrementButton.OnPush; _originalBombDecrementHandler = _bombsDecrementButton.OnPush; _bombsIncrementButton.OnPush = () => { FreeplayDevice.StartCoroutine(IncrementBombCount()); }; _bombsDecrementButton.OnPush = () => { FreeplayDevice.StartCoroutine(DecrementBombCount()); }; }
public FreeplayCommander(FreeplayDevice freeplayDevice) { FreeplayDevice = freeplayDevice; Selectable = FreeplayDevice.GetComponent <Selectable>(); SelectableChildren = Selectable.Children; FloatingHoldable = FreeplayDevice.GetComponent <FloatingHoldable>(); SelectableManager = KTInputManager.Instance.SelectableManager; }
public static IEnumerator ModifyFreeplayDevice(bool firstTime) { yield return(null); SetupRoom setupRoom = FindObjectOfType <SetupRoom>(); if (setupRoom) { FreeplayDevice freeplayDevice = setupRoom.FreeplayDevice; ExecOnDescendants(freeplayDevice.gameObject, gameObj => { string gameObjName = gameObj.name; if (gameObjName == "FreeplayLabel" || gameObjName == "Free Play Label") { gameObj.GetComponent <TMPro.TextMeshPro>().text = CurrentMode == Mode.Normal ? Localization.GetLocalizedString($"FreeplayDevice/label_free{(gameObjName == "FreeplayLabel" ? "playInnerTitle" : "PlayCover")}") : $"{CurrentMode} mode"; } }); freeplayDevice.CurrentSettings.Time = CurrentMode == Mode.Time ? Modes.settings.TimeModeStartingTime * 60 : originalTime; TimeSpan timeSpan = TimeSpan.FromSeconds(freeplayDevice.CurrentSettings.Time); freeplayDevice.TimeText.text = string.Format("{0}:{1:00}", (int)timeSpan.TotalMinutes, timeSpan.Seconds); if (!firstTime) { yield break; } if (CurrentMode == Mode.Normal) { originalTime = freeplayDevice.CurrentSettings.Time; } freeplayDevice.TimeIncrement.OnPush += delegate { ReflectedTypes.IsInteractingField.SetValue(freeplayDevice.TimeIncrement, true); }; freeplayDevice.TimeIncrement.OnInteractEnded += delegate { originalTime = freeplayDevice.CurrentSettings.Time; if (CurrentMode != Mode.Time) { return; } Modes.settings.TimeModeStartingTime = freeplayDevice.CurrentSettings.Time / 60; Modes.modConfig.Write(Modes.settings); }; freeplayDevice.TimeDecrement.OnPush += delegate { ReflectedTypes.IsInteractingField.SetValue(freeplayDevice.TimeDecrement, true); }; freeplayDevice.TimeDecrement.OnInteractEnded += delegate { originalTime = freeplayDevice.CurrentSettings.Time; if (CurrentMode != Mode.Time) { return; } Modes.settings.TimeModeStartingTime = freeplayDevice.CurrentSettings.Time / 60; Modes.modConfig.Write(Modes.settings); }; } }
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 IEnumerator HandleInput() { Selectable = (MonoBehaviour)FreeplayDevice.GetComponent(_selectableType); SelectableChildren = (MonoBehaviour[])_childrenField.GetValue(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; } int holdState = (int)_holdStateProperty.GetValue(FloatingHoldable, null); if (holdState != 0) { _index = 0; IEnumerator hold = HoldFreeplayDevice(); while (hold.MoveNext()) { yield return(hold.Current); } ToggleIndex(); 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)) { IEnumerator handler = null; switch (_index) { case freeplaySelection.Timer: handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementBombTimer() : IncrementBombTimer(); break; case freeplaySelection.Bombs: handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementBombCount() : IncrementBombCount(); break; case freeplaySelection.Modules: handler = Input.GetKeyDown(KeyCode.LeftArrow) ? DecrementModuleCount() : IncrementModuleCount(); break; case freeplaySelection.Needy: handler = SetNeedy(); break; case freeplaySelection.Hardcore: handler = SetHardcore(); break; case freeplaySelection.ModsOnly: handler = SetModsOnly(); break; } if (handler == null) { yield break; } while (handler.MoveNext()) { yield return(handler.Current); } } }