void InputListener() { if (MinigameInputHelper.IsButton1Down(1) || MinigameInputHelper.IsButton1Down(2)) { //disable the confetti confetti.SetActive(false); SceneTransitionController.Instance.TransitionToScene("MainMenu"); } }
// Called every frame private void Update() { // Update the description, character by character if (!descr_fully_visible()) { time_til_next_char -= Time.deltaTime; while (time_til_next_char < 0 && !descr_fully_visible()) { incr_descr_length(); } } // Check for input from this player, to select an option (as long as the animation is done) if (descr_fully_visible()) { if (current_element is TimeBytes_Fork) { if (MinigameInputHelper.IsButton1Down(player)) { TimeBytes_Fork fork = current_element as TimeBytes_Fork; choose_option(fork.Option1); } else if (MinigameInputHelper.IsButton2Down(player)) { TimeBytes_Fork fork = current_element as TimeBytes_Fork; choose_option(fork.Option1); } } else if (current_element is TimeBytes_Extension) { if (MinigameInputHelper.IsButton1Down(player) || MinigameInputHelper.IsButton2Down(player)) { TimeBytes_Extension extension = current_element as TimeBytes_Extension; choose_option(extension.continuation); } } } // If any joystick input was given, skip the rest of the text animation bool hor_skip = Mathf.Abs(MinigameInputHelper.GetHorizontalAxis(player)) > TimeBytes_Config.joystick_skip_thresh; bool vert_skip = Mathf.Abs(MinigameInputHelper.GetVerticalAxis(player)) > TimeBytes_Config.joystick_skip_thresh; if (hor_skip || vert_skip) { description_TMP.maxVisibleCharacters = description_TMP.text.Length; } }
// Update is called once per frame void Update() { if (MinigameInputHelper.IsButton1Down(1) || MinigameInputHelper.IsButton2Down(1) || MinigameInputHelper.IsButton1Down(2) || MinigameInputHelper.IsButton2Down(2)) { if (selected == 1) { cooldown2 = 0.7f; if (side == "left") { calibration -= (calibration <= -1 ? 0.0f : 0.01f); } else if (side == "right") { calibration += (calibration < 1 ? 0.01f : 0.0f); } } else if (selected == 0) { cooldown2 = 0.7f; if (side == "left") { masterVolume -= (masterVolume <= 0 ? 0 : 1); } else if (side == "right") { masterVolume += (masterVolume <= 100 ? 1 : 0); } } else if (selected == 2) { calibra = calibration; volume = masterVolume; } else if (selected == 3) { returnToMainMenu(); } } float joystickx1, joystickx2; float joysticky1, joysticky2; if (cooldown > 0) { cooldown -= Time.deltaTime; } else { joystickx1 = MinigameInputHelper.GetHorizontalAxis(1); joystickx2 = MinigameInputHelper.GetHorizontalAxis(2); joysticky1 = MinigameInputHelper.GetVerticalAxis(1); joysticky2 = MinigameInputHelper.GetVerticalAxis(2); if (joysticky1 < 0 || joysticky2 < 0) //scroll up { selected = (selected + 1) % 4; cooldown = 0.28f; } else if (joysticky1 > 0 || joysticky2 > 0) //scroll down { selected = (selected - 1 + 4) % 4; cooldown = 0.28f; } if (selected < 2) { if (joystickx1 < 0 || joystickx2 < 0) //left nudge { side = "left"; cooldown2 = 1.3f; if (selected == 0) { masterVolume -= (masterVolume <= 0 ? 0 : 1); cooldown = 0.1f; } else { calibration -= (calibration <= -1 ? 0.0f : 0.01f); cooldown = 0.1f; } } else if (joystickx1 > 0 || joystickx2 > 0) //right nudge { side = "right"; cooldown2 = 1.3f; if (selected == 0) { masterVolume += (masterVolume < 100 ? 1 : 0); cooldown = 0.1f; } else { calibration += (calibration <= 1 ? 0.01f : 0.0f); cooldown = 0.1f; } } } } //eventCap.GetComponent<UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); if (true) { if (selected == 0) { volumeSliderTool[1].GetComponent <Button>().Select(); } else if (selected == 1) { calibratorTool[1].GetComponent <Button>().Select(); } else if (selected == 2) { applyButtn.GetComponent <Button>().Select(); } else { returnButtn.GetComponent <Button>().Select(); } } if (cooldown2 > 0) { if (side == "left") { if (selected == 0) { volumeSliderTool[0].GetComponent <Button>().Select(); } else { calibratorTool[0].GetComponent <Button>().Select(); } } else { if (selected == 0) { volumeSliderTool[2].GetComponent <Button>().Select(); } else { calibratorTool[2].GetComponent <Button>().Select(); } } cooldown2 -= Time.deltaTime; } t_calibration.text = "Delay: " + (Mathf.Round(calibration * 100) / 100).ToString(); calibration_bar.fillAmount = (calibration + 1) / 2; t_m_volume.text = "Master Volume: " + masterVolume.ToString(); volume_bar.fillAmount = ((float)masterVolume) / 100; }