public override void Update() { room.Update(); wiggler.Update(Time.time); reverseWiggler.Update(Time.time); if (solved) { return; } room.hintWhenTouched((touched) => {}, messagePromptCoordinator, sensor); foreach (var gameObject in room.interactions.Keys) { prodResponses[gameObject] = room.interactions[gameObject]; } messagePromptCoordinator.hintWhenTouched(GameObject => {}, sensor, Time.time, prodResponses); if (room.guySplitDistance >= MAX_SPLIT - Mathf.Epsilon) { messagePromptCoordinator.solve(this, "pull guy in half"); endScene(); } else if (PinchingGuy()) { var distance = PinchDistance(); var horizontal_distance = Math.Min(Math.Abs(distance.x), MAX_SPLIT); room.separateHalves(horizontal_distance); messagePromptCoordinator.progress("pull guy apart"); } }
public override void Update() { if (!(Selected && Focused)) { goto End; } if (Input.MenuRight.Pressed && selectedDigit < (digits.Length - 1)) { selectedDigit = Math.Min(selectedDigit + 1, (digits.Length - 1)); wigglerDigits[selectedDigit].Start(); Audio.Play(SFX.ui_main_roll_down); } else if (Input.MenuLeft.Pressed && selectedDigit > 0) { selectedDigit = Math.Max(selectedDigit - 1, 0); wigglerDigits[selectedDigit].Start(); Audio.Play(SFX.ui_main_roll_up); } else if (Input.MenuDown.Pressed) { UpdateDigits(selectedDigit, -1); } else if (Input.MenuUp.Pressed) { UpdateDigits(selectedDigit, +1); } else if (Input.MenuConfirm.Pressed) { if (playing != null) { Audio.Stop(playing); } if (!string.IsNullOrEmpty(selectedPath)) { playing = Audio.Play(selectedPath); } } else if (Input.MenuCancel.Pressed || Input.Pause.Pressed || Input.ESC.Pressed) { Focused = false; Audio.Play(SFX.ui_main_button_back); Overworld.Goto <OuiModOptions>(); } End: pressedTimer -= Engine.DeltaTime; timer += Engine.DeltaTime; for (int i = 0; i < digits.Length; i++) { wigglerDigits[i].Update(); } wigglerPath.Update(); wigglerBankPath.Update(); }
public override void Update() { float now = Time.time; wiggler.Update(now); notSameCycler.Update(now); if (solved) { return; } if (shapes.touchedAtSameTime(now) && triangleShowing()) { messagePromptCoordinator.clearTouch(); messagePromptCoordinator.progress("stop shapes from changing"); Handheld.Vibrate(); wiggler.wiggleNow(now); endScene(); } else { messagePromptCoordinator.hintWhenTouched(GameObject => {}, sensor, now, new Dictionary <GameObject, ActionResponsePair[]> { { circle.gameObject, new [] { new ActionResponsePair("stop circle from changing", new[] { "Nope." }) } }, { triangle.gameObject, new [] { new ActionResponsePair("stop triangle from changing", new[] { "Nope." }) } }, }); } AnimateShapes(now); // if touched circle, draw its bright first frame if (sensor.changeInsideSprite(Camera.main, circle)) { circle.setFrame(0); circle.Animate(); } // if touched triangle, ditto if (sensor.changeInsideSprite(Camera.main, triangle) && triangleShowing()) { triangle.setFrame(0); triangle.Animate(); } }
public override void Update() { bool wasFocused = Focused; // Only "focus" if we're not using the keyboard for input Focused = wasFocused && !UseKeyboardInput; base.Update(); // TODO: Rewrite or study and document the following code. // It stems from OuiFileNaming. if (!(Selected && Focused)) { goto End; } if (Input.MenuRight.Pressed && (optionsIndex < 2 || !selectingOptions)) { if (selectingOptions) { // move 1 option right. optionsIndex = Math.Min(optionsIndex + 1, 2); } else { // move right on the keyboard until hitting content. do { index = (index + 1) % letters[line].Length; } while (!isOptionValid(line, index)); } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuLeft.Pressed && (optionsIndex > 0 || !selectingOptions)) { if (selectingOptions) { // move 1 option left. optionsIndex = Math.Max(optionsIndex - 1, 0); } else { // move left on the keyboard until hitting content. do { index = (index + letters[line].Length - 1) % letters[line].Length; } while (!isOptionValid(line, index)); } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuDown.Pressed && !selectingOptions) { int lineNext = line + 1; bool shouldSwitchToOptions = true; // scroll down until hitting a valid character for (; lineNext < letters.Length; lineNext++) { if (index < letters[lineNext].Length && isOptionValid(lineNext, index)) { shouldSwitchToOptions = false; break; } } if (shouldSwitchToOptions) { // we scrolled down to the bottom; switch to options selectingOptions = true; // select the middle option; it's always the closest one because the keyboard is narrow enough. optionsIndex = 1; } else { line = lineNext; } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if ((Input.MenuUp.Pressed || (selectingOptions && Value.Length <= 0 && optionsIndex > 0)) && (line > 0 || selectingOptions)) { if (selectingOptions) { // we were in options and pressed Up; go back to the bottom of the keyboard. line = letters.Length; selectingOptions = false; // if we selected option 0, focus on the leftmost row; if we selected option 1, focus on the middle row; if we selected option 2, focus on the rightmost row index = optionsIndex * 2; } // go up until hitting a valid character do { line--; } while (line > 0 && (index >= letters[line].Length || !isOptionValid(line, index))); // go left until hitting a valid character while (index >= letters[line].Length || !isOptionValid(line, index)) { index--; } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuConfirm.Pressed) { if (selectingOptions) { if (optionsIndex == 0) { Cancel(); } else if (optionsIndex == 1) { Backspace(); } else if (optionsIndex == 2) { Finish(); } } else { OnTextInput(letters[line][index]); } } else if (Input.MenuCancel.Pressed) { if (Value.Length > 0) { Backspace(); } else { Cancel(); } } else if (Input.Pause.Pressed) { Finish(); } End: if (wasFocused && !Focused) { if (Input.ESC) { Cancel(); wasFocused = false; } } Focused = wasFocused; pressedTimer -= Engine.DeltaTime; timer += Engine.DeltaTime; wiggler.Update(); }
public override void Update() { bool wasFocused = Focused; // Only "focus" if the input method is a gamepad, not a keyboard. Focused = wasFocused && MInput.GamePads[Input.Gamepad].Attached; base.Update(); // TODO: Rewrite or study and document the following code. // It stems from OuiFileNaming. if (!(Selected && Focused)) { goto End; } if (Input.MenuRight.Pressed && (optionsIndex < 3 || !selectingOptions) && (Value.Length > 0 || !selectingOptions)) { if (selectingOptions) { optionsIndex = Math.Min(optionsIndex + 1, 3); } else { do { index = (index + 1) % letters[line].Length; } while (letters[line][index] == ' '); } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuLeft.Pressed && (optionsIndex > 0 || !selectingOptions)) { if (selectingOptions) { optionsIndex = Math.Max(optionsIndex - 1, 0); } else { do { index = (index + letters[line].Length - 1) % letters[line].Length; } while (letters[line][index] == ' '); } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuDown.Pressed && !selectingOptions) { int lineNext = line + 1; bool something = true; for (; lineNext < letters.Length; lineNext++) { if (index < letters[lineNext].Length && letters[lineNext][index] != ' ') { something = false; break; } } if (something) { selectingOptions = true; } else { line = lineNext; } if (selectingOptions) { float pos = index * widestLetter; float offs = boxWidth - boxPadding * 2f; if (Value.Length == 0 || pos < cancelWidth + (offs - cancelWidth - beginWidth - backspaceWidth - spaceWidth - widestLetter * 3f) / 2f) { optionsIndex = 0; } else if (pos < offs - beginWidth - backspaceWidth - widestLetter * 2f) { optionsIndex = 1; } else if (pos < offs - beginWidth - widestLetter) { optionsIndex = 2; } else { optionsIndex = 3; } } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if ((Input.MenuUp.Pressed || (selectingOptions && Value.Length <= 0 && optionsIndex > 0)) && (line > 0 || selectingOptions)) { if (selectingOptions) { line = letters.Length; selectingOptions = false; float offs = boxWidth - boxPadding * 2f; if (optionsIndex == 0) { index = (int)(cancelWidth / 2f / widestLetter); } else if (optionsIndex == 1) { index = (int)((offs - beginWidth - backspaceWidth - spaceWidth / 2f - widestLetter * 2f) / widestLetter); } else if (optionsIndex == 2) { index = (int)((offs - beginWidth - backspaceWidth / 2f - widestLetter) / widestLetter); } else if (optionsIndex == 3) { index = (int)((offs - beginWidth / 2f) / widestLetter); } } do { line--; } while (line > 0 && (index >= letters[line].Length || letters[line][index] == ' ')); while (index >= letters[line].Length || letters[line][index] == ' ') { index--; } wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_roll); } else if (Input.MenuConfirm.Pressed) { if (selectingOptions) { if (optionsIndex == 0) { Cancel(); } else if (optionsIndex == 1 && Value.Length > 0) { Space(); } else if (optionsIndex == 2) { Backspace(); } else if (optionsIndex == 3) { Finish(); } } else if (Value.Length < MaxValueLength) { Value += letters[line][index].ToString(); wiggler.Start(); Audio.Play(SFX.ui_main_rename_entry_char); } else { Audio.Play(SFX.ui_main_button_invalid); } } else if (Input.MenuCancel.Pressed) { if (Value.Length > 0) { Backspace(); } else { Cancel(); } } else if (Input.Pause.Pressed) { Finish(); } End: if (wasFocused && !Focused) { if (Input.ESC) { Cancel(); wasFocused = false; } } Focused = wasFocused; pressedTimer -= Engine.DeltaTime; timer += Engine.DeltaTime; wiggler.Update(); }
public override void Update() { musicParamMenuEase = Calc.Approach(musicParamMenuEase, musicParamMenu?.Focused ?? false ? 1 : 0, Engine.DeltaTime * 2f); if (!(Selected && Focused)) { goto End; } if (musicParamMenu.Focused) { musicParamMenu.Update(); } if (Focused && musicParamMenu != null && Input.MenuJournal.Pressed && musicParamMenu.GetItems().Count != 0) { musicParamMenu.Selection = musicParamMenu.FirstPossibleSelection; musicParamMenu.Focused = !musicParamMenu.Focused; } if (Input.MenuRight.Pressed && selectedDigit < (digits.Length - 1) && !musicParamMenu.Focused) { selectedDigit = Math.Min(selectedDigit + 1, (digits.Length - 1)); wigglerDigits[selectedDigit].Start(); Audio.Play(SFX.ui_main_roll_down); } else if (Input.MenuLeft.Pressed && selectedDigit > 0 && !musicParamMenu.Focused) { selectedDigit = Math.Max(selectedDigit - 1, 0); wigglerDigits[selectedDigit].Start(); Audio.Play(SFX.ui_main_roll_up); } else if (Input.MenuDown.Pressed && !musicParamMenu.Focused) { UpdateDigits(selectedDigit, -1); } else if (Input.MenuUp.Pressed && !musicParamMenu.Focused) { UpdateDigits(selectedDigit, +1); } else if (Input.MenuConfirm.Pressed) { if (playing != null) { Audio.Stop(playing); } if (!string.IsNullOrEmpty(selectedPath)) { playing = playWithMusicParams(selectedPath, musicParams); playingPath = selectedPath; } } else if (Input.MenuCancel.Pressed || Input.Pause.Pressed || Input.ESC.Pressed) { if (musicParamMenu.Focused) { musicParamMenu.Focused = false; } else { Focused = false; Audio.Play(SFX.ui_main_button_back); Overworld.Goto <OuiModOptions>(); } } End: pressedTimer -= Engine.DeltaTime; timer += Engine.DeltaTime; for (int i = 0; i < digits.Length; i++) { wigglerDigits[i].Update(); } wigglerPath.Update(); wigglerBankPath.Update(); }