// Update is called once per frame void Update() { if (hand.isBurned()) { rbody.MovePosition(rbody.transform.position + new Vector3(0, hand.getBurnRatio()) * Time.deltaTime * moveSpeed); rbody.MoveRotation(Mathf.Lerp(rbody.rotation, 2 * maxRot * Random.Range(-1.0f, 1.0f), 0.4f)); } else { float HorizontalAxis = MinigameInputHelper.GetHorizontalAxis(hand.player); float VerticalAxis = MinigameInputHelper.GetVerticalAxis(hand.player); rbody.MovePosition(rbody.transform.position + new Vector3(HorizontalAxis, VerticalAxis) * Time.deltaTime * moveSpeed); rbody.MoveRotation(Mathf.Lerp(rbody.rotation, maxRot * -HorizontalAxis, 0.1f)); } }
// 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() { //MinigameInputHelper.IsButton1Down(player) float v_axis = MinigameInputHelper.GetVerticalAxis(player); if (v_axis > 0 && !up && place > min && !select) { place--; up = true; transform.Translate( Vector3.up * move_amnt ); down = false; } if (v_axis < 0 && !down && place < max && !select) { place++; down = true; transform.Translate( Vector3.down * move_amnt ); up = false; } if (v_axis == 0) { up = false; down = false; } if (MinigameInputHelper.IsButton1Down(player)) { select = !select; } if (place == 0) { TYPE = 0; } else if (place == 1) { TYPE = 4; } else if (place == 2) { TYPE = ((int)(Random.Range(0, 2)) * 4); //random between the two } }
// Update is called once per frame void Update() { // checks for button 2 input every frame if (MinigameInputHelper.IsButton2Down(playerNumber) && hasHook) { // gets player number playerNumber = GetComponent <MovementController>().playerNumber; // gets direction player is moving float xDirection = MinigameInputHelper.GetHorizontalAxis(playerNumber); float yDirection = MinigameInputHelper.GetVerticalAxis(playerNumber); // only shoot the hook if the player is not sitting still if (xDirection != 0 || yDirection != 0) { shootHookInDirection(this.gameObject.transform, xDirection, yDirection); } } }
void CheckUserInput() { time = time + Time.deltaTime; //holds /*if (Input.GetKeyDown(KeyCode.RightShift) || Input.GetKeyDown(KeyCode.LeftShift) || && FindObjectOfType<Game>().GetHoldTime()) || { || enabled = false; || FindObjectOfType<Game>().SetNull(this); || transform.rotation = Quaternion.identity; || transform.position = FindObjectOfType<Game>().transform.position + 6 * Vector3.right + 9 * Vector3.up; || if (!FindObjectOfType<Game>().GetHold()) || { || FindObjectOfType<Game>().SetHold(this); || FindObjectOfType<Spawner>().SpawnNext(); || } || else || { || Tetromino t = FindObjectOfType<Game>().GetHoldTetromino(); || t.enabled = true; || FindObjectOfType<Game>().SetHold(this); || if (t.whereSpawn) || { || t.transform.position += 38 * Vector3.up / 4 + 9 * Vector3.right / 4 + Vector3.down / 4; + } + else + { + t.transform.position = 38 * Vector3.up / 4 + 9 * Vector3.right / 4 + Vector3.left / 4; + } + } + FindObjectOfType<Game>().SetHoldTime(false); + }*/ //go right (joystick right) if (MinigameInputHelper.GetHorizontalAxis(2) > 0 && time > nextMove) { nextMove = time + nextMoveDelta; transform.position += Vector3.right / 2; if (!CheckIsValidPosition()) { transform.position += Vector3.left / 2; } else { FindObjectOfType <Game_2>().UpdateGrid(this); } nextMove = nextMove - time; time = 0.0F; } //go left (joystick left) else if (MinigameInputHelper.GetHorizontalAxis(2) < 0 && time > nextMove) { nextMove = time + nextMoveDelta; transform.position += Vector3.left / 2; if (!CheckIsValidPosition()) { transform.position += Vector3.right / 2; } else { FindObjectOfType <Game_2>().UpdateGrid(this); } nextMove = nextMove - time; time = 0.0F; } //rotate (joystick up) else if (isVerticalReset && MinigameInputHelper.GetVerticalAxis(2) > 0) { transform.Rotate(0, 0, -90); foreach (Transform mino in transform) { mino.Rotate(0, 0, -90); } if (!CheckIsValidPosition()) { transform.Rotate(0, 0, 90); foreach (Transform mino in transform) { mino.Rotate(0, 0, 90); } } else { FindObjectOfType <Game_2>().UpdateGrid(this); } } //rotate other direction (other button) else if (MinigameInputHelper.IsButton2Down(2)) { transform.Rotate(0, 0, 90); foreach (Transform mino in transform) { mino.Rotate(0, 0, 90); } if (!CheckIsValidPosition()) { transform.Rotate(0, 0, -90); foreach (Transform mino in transform) { mino.Rotate(0, 0, -90); } } else { FindObjectOfType <Game_2>().UpdateGrid(this); } } //hard drop (other button) else if (MinigameInputHelper.IsButton1Down(2)) { while (CheckIsValidPosition()) { transform.position += Vector3.down / 2; } transform.position += Vector3.up / 2; FindObjectOfType <Game_2>().UpdateGrid(this); enabled = false; FindObjectOfType <Game_2>().DecreaseAboveRows(); FindObjectOfType <Spawner_2>().SpawnNext(); } //go down (joystick down) else if (((MinigameInputHelper.GetVerticalAxis(2) < 0) || Time.time - fallTime >= fallSpeed) && time > nextMove) { nextMove = time + nextMoveDelta; transform.position += Vector3.down / 2; fallTime = Time.time; if (!CheckIsValidPosition()) { transform.position += Vector3.up / 2; enabled = false; FindObjectOfType <Game_2>().UpdateGrid(this); FindObjectOfType <Game_2>().DecreaseAboveRows(); FindObjectOfType <Spawner_2>().SpawnNext(); //FindObjectOfType<Spawner>().SpawnPreview(); } else { FindObjectOfType <Game_2>().UpdateGrid(this); } nextMove = nextMove - time; time = 0.0F; } isVerticalReset = !MinigameInputHelper.IsVerticalAxisInUse(2); }
private void checkForInput() { float vertical = MinigameInputHelper.GetVerticalAxis(2); float horizontal = MinigameInputHelper.GetHorizontalAxis(2); int switchTo = -1; if (vertical == 1f && horizontal == 0f) { switchTo = 0; } else if (vertical == 1f && horizontal == 1f) { switchTo = 1; } else if (vertical == 0f && horizontal == 1f) { switchTo = 2; } else if (vertical == -1f && horizontal == 1f) { switchTo = 3; } else if (vertical == -1f && horizontal == 0f) { switchTo = 4; } else if (vertical == -1f && horizontal == -1f) { switchTo = 5; } else if (vertical == 0f && horizontal == -1f) { switchTo = 6; } else if (vertical == 1f && horizontal == -1f) { switchTo = 7; } if (switchTo == -1) { if (currentDrum != -1) { drums[currentDrum].deselectDrum(); frogDrummer.selectSprite(8); } currentDrum = -1; } else if (switchTo != currentDrum) { if (currentDrum != -1) { drums[currentDrum].deselectDrum(); } currentDrum = switchTo; drums[switchTo].selectDrum(); frogDrummer.selectSprite(switchTo); } if (MinigameInputHelper.IsButton1Down(2) || MinigameInputHelper.IsButton2Down(2)) { if (currentDrum != -1) { processScore(drums[currentDrum].hitDrum()); } } }
// Update is called once per frame void Update() { //Don't take any input if stunned if (stunned) { stunTime -= Time.deltaTime; if (stunTime <= 0) { stunned = false; } thisRigidBody.velocity = new Vector2(0, thisRigidBody.velocity.y); } else { //Horizontal movement. Maintains y velocity inputVector = new Vector2(MinigameInputHelper.GetHorizontalAxis(playerNumber) * moveSpeed, thisRigidBody.velocity.y); if (inputVector != thisRigidBody.velocity && !isDashing) { thisRigidBody.velocity = inputVector; } //Jump input if (MinigameInputHelper.IsButton1Down(playerNumber) || MinigameInputHelper.GetVerticalAxis(playerNumber) == 1) { //Only jumps if the player is not already jumping or falling if (thisRigidBody.velocity.y < 0.01f && thisRigidBody.velocity.y > -0.01f) { //jump by adding upward force thisRigidBody.AddForce(transform.up * jumpForce, ForceMode2D.Impulse); doubleJumpUsed = false; animator.SetBool("isJumping", true); } //Double jump else if (!doubleJumpUsed && hasDoubleJump) { thisRigidBody.velocity = new Vector3(thisRigidBody.velocity.x, 0, 0); thisRigidBody.AddForce(transform.up * jumpForce, ForceMode2D.Impulse); doubleJumpUsed = true; } } else if (thisRigidBody.velocity.y < 0.01f && thisRigidBody.velocity.y > -0.01f) { animator.SetBool("isJumping", false); } // Dash if (MinigameInputHelper.IsButton2Down(playerNumber) && hasDash && !isDashing) { if (this.gameObject.GetComponent <SpriteRenderer>().flipX == false) { thisRigidBody.AddForce(transform.right * 15f, ForceMode2D.Impulse); isDashing = true; Invoke("resetDash", 0.5f); } else { thisRigidBody.AddForce(transform.right * -15f, ForceMode2D.Impulse); isDashing = true; Invoke("resetDash", 0.5f); } } //Jetpack input if (MinigameInputHelper.IsButton1Held(playerNumber) && hasJetPack) { velVector = new Vector3(thisRigidBody.velocity.x, jetPackVelocity, 0); thisRigidBody.velocity = velVector; } } //Animation stuff tagged = GetComponent <Tag>().isTagged; animator.SetFloat("verticalVelocity", thisRigidBody.velocity.y); GameObject bomb = GetComponent <Tag>().bomb; //Adjust speed for moving platforms if (transform.parent != null && transform.parent.gameObject.GetComponent <Rigidbody2D>() != null) { Vector2 parentVelocity = transform.parent.gameObject.GetComponent <Rigidbody2D>().velocity; thisRigidBody.velocity += parentVelocity; animator.SetFloat("horizontalSpeed", Mathf.Abs(thisRigidBody.velocity.x - parentVelocity.x)); if (thisRigidBody.velocity.x - parentVelocity.x > 0.1) { this.gameObject.GetComponent <SpriteRenderer>().flipX = false; bomb.transform.localPosition = new Vector3(Mathf.Abs(bomb.transform.localPosition.x), bomb.transform.localPosition.y, bomb.transform.localPosition.z); } else if (thisRigidBody.velocity.x - parentVelocity.x < -0.1) { this.gameObject.GetComponent <SpriteRenderer>().flipX = true; bomb.transform.localPosition = new Vector3(-1f * Mathf.Abs(bomb.transform.localPosition.x), bomb.transform.localPosition.y, bomb.transform.localPosition.z); } } else { animator.SetFloat("horizontalSpeed", Mathf.Abs(thisRigidBody.velocity.x)); //Flip the sprite if (thisRigidBody.velocity.x > 0.1) { this.gameObject.GetComponent <SpriteRenderer>().flipX = false; bomb.transform.localPosition = new Vector3(Mathf.Abs(bomb.transform.localPosition.x), bomb.transform.localPosition.y, bomb.transform.localPosition.z); } else if (thisRigidBody.velocity.x < -0.1) { this.gameObject.GetComponent <SpriteRenderer>().flipX = true; bomb.transform.localPosition = new Vector3(-1f * Mathf.Abs(bomb.transform.localPosition.x), bomb.transform.localPosition.y, bomb.transform.localPosition.z); } } //Explode if game is complete float completion = MinigameController.Instance.GetPercentTimePassed(); if (completion >= 1) { bombAnimator.SetTrigger("explode"); //Stop bomb particles bombAnimator.gameObject.GetComponent <ParticleSystem>().Stop(); bombAnimator.gameObject.GetComponent <ParticleSystem>().Clear(); //Scale the bomb to make the exlosion big bombTransform.localScale = new Vector2(2, 2); } }
// Update is called once per frame void Update() { // For preview purposes, update current angle to the start angle in editor only if (!Application.isPlaying) { CurrentAngleDegrees = StartAngleDegrees; } // Set position based on Current Angle Vector2 OffsetVector = new Vector2(Mathf.Cos(Mathf.Deg2Rad * CurrentAngleDegrees), Mathf.Sin(Mathf.Deg2Rad * CurrentAngleDegrees)); transform.position = RotationCenter.position + (Vector3)OffsetVector * RadiusAwayFromCenter; //Set rotation based on Current Angle transform.rotation = Quaternion.Euler(0, 0, CurrentAngleDegrees); // Update the Current Angle to move to target direction Vector2 TargetVector = new Vector2(MinigameInputHelper.GetHorizontalAxis(PlayerNum), MinigameInputHelper.GetVerticalAxis(PlayerNum)).normalized; if (Mathf.Abs(TargetVector.x) > 0 || Mathf.Abs(TargetVector.y) > 0) { float TargetAngleDegrees = Mathf.Rad2Deg * Mathf.Atan2(TargetVector.y, TargetVector.x); float AngleDistance = Mathf.DeltaAngle(CurrentAngleDegrees, TargetAngleDegrees); float AngleDirection = Mathf.Sign(AngleDistance); if (Mathf.Abs(AngleDistance) < RotationSpeedDegreePerSecond) { CurrentAngleDegrees = TargetAngleDegrees; } else { CurrentAngleDegrees += RotationSpeedDegreePerSecond * AngleDirection; } } }
void Update() { // load the level select menu if any button is pressed if (MinigameInputHelper.IsButton1Up(1) || MinigameInputHelper.IsButton1Up(2) || MinigameInputHelper.IsButton2Up(1) || MinigameInputHelper.IsButton2Up(2) ) { if (selected == 0) { LoadLevelMenu(); } else if (selected == 1) { LoadSettings(); } else if (selected == 2) { MinigameController.Instance.FinishGame(LastMinigameFinish.NONE);; } } if (coolDown <= 0) { float joystick1 = MinigameInputHelper.GetVerticalAxis(1); float joystick2 = MinigameInputHelper.GetVerticalAxis(2); if (joystick1 > 0 || joystick2 > 0) { selected = (selected + 2) % 3; coolDown = 0.3f; } else if (joystick1 < 0 || joystick2 < 0) { selected = (selected + 1) % 3; coolDown = 0.3f; } } if (selected == 0) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); play.GetComponent <Button>().Select(); } else if (selected == 1) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); settings.GetComponent <Button>().Select(); } else if (selected == 2) { myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); exit.GetComponent <Button>().Select(); } if (coolDown > 0) { coolDown -= Time.deltaTime; } }
// Update is called once per frame void Update() { if (MinigameInputHelper.GetHorizontalAxis(player) < 0.1 && MinigameInputHelper.GetHorizontalAxis(player) > -0.1 /*&& * animator.GetInteger("state") < 2 + TYPE*/) { animator.SetInteger("state", 0 + TYPE); } else if (animator.GetInteger("state") < 2 + TYPE) { animator.SetInteger("state", 1 + TYPE); } jumpTime += Time.deltaTime; if (animator.GetInteger("state") == 2 + TYPE && jumpTime > 1 + TYPE) { jumpTime = 0; animator.SetInteger("state", 0 + TYPE); } pos = set_vec2(this.transform.position.x, this.transform.position.y); pos2 = set_vec2(other.transform.position.x, other.transform.position.y); read_vel2 = (pos2 - pos2_old) / Time.deltaTime; pos2_old = set_vec2(other.transform.position.x, other.transform.position.y); joystick = set_vec2( MinigameInputHelper.GetHorizontalAxis(player), MinigameInputHelper.GetVerticalAxis(player) ); float ground = (platform.pos.y + platform.height + (float)(0.3 * playerHeight)); if (joystick.y > 0 && (up == false || pos.y <= ground + 0.1)) { if (pos.x <= platform.pos.x + platform.width / 2 && pos.x >= platform.pos.x - platform.width / 2 && pos.y <= ground) { jump_count = 0; } if (jump_count < max_jump) // || (double_jump && jump_count < 1)){ { jump(); up = true; } } if (joystick.y > 0) { up = true; } else { up = false; } //collision with platform if (within_bounds(pos, platform) && !up) { vel.y = 0; //transform.position.y = platform; transform.Translate(0f, (float)(ground - pos.y), 0f); } else if (pos.y < -8) { vel.y = 0; //stops from infinite falling vel.x = 0; double spawn; animator.SetInteger("state", 1); if (pos2.x < platform.pos.x) { spawn = 6.5; //actually fell on the left side gameObject.GetComponent <ActionScript>().setDirection(true); dir = -1; } else { spawn = -6.5; //assuming fell on right side gameObject.GetComponent <ActionScript>().setDirection(false); dir = 1; } const int start_y = 5; transform.Translate((float)(spawn - pos.x), (float)(start_y - pos.y), 0f); other.GetComponent <HealthScript>().TakeDamage(5); sound.PlayDie(); } if (pos.y <= ground) //+thresh? { if (pos.x <= platform.pos.x + platform.width / 2 && pos.x >= platform.pos.x - platform.width / 2 && !up) { jump_count = 0; } run((run_vel / 10) * joystick.x); } else if (abs(joystick.x) > 0) { run((float)0.9 * joystick.x); //slight air movement } else { accel.x = (float)(-0.001 * vel.x); } vel.x += accel.x; vel.y += accel.y; vel.x = clamp(-max_vel, max_vel, vel.x); //clamped at max_vel m/s vel.y = clamp(-2 * max_vel, 2 * max_vel, vel.y); //terminal velocity if (abs(pos.x - pos2.x) <= playerWidth && abs(pos.y - pos2.y) <= playerHeight) { collision(ground); is_in = true; } else { is_in = false; } float ballcharge = this.GetComponent <ActionScript>().ballCharge; //arrow.transform.Translate(0, 0, 0); if (MinigameInputHelper.GetHorizontalAxis(player) < 0) { dir = -1; } else if (MinigameInputHelper.GetHorizontalAxis(player) > 0) { dir = 1; } if (ballcharge > 0 && TYPE == 0) { arrow.transform.Rotate(new Vector3(0, 0, 1), dir * ((3 * ballcharge) * Time.deltaTime)); arrow.transform.localScale = new Vector3((float)(0.2), (float)(0.2), 1); } else { arrow.transform.rotation = Quaternion.identity; arrow.transform.localScale = new Vector3(0, 0, 0); } //if(player == 0){ if (dir < 0) { arrow.GetComponent <SpriteRenderer>().flipX = false; } else if (dir > 0) { arrow.GetComponent <SpriteRenderer>().flipX = true; } this.transform.localScale = new Vector3((float)(1.2 * playerWidth), (float)(1.2 * playerHeight), 1); transform.Translate( vel.x * Time.deltaTime, vel.y * Time.deltaTime, 0.0f ); }
void Update() { // load the level select menu if any button is pressed if (MinigameInputHelper.IsButton1Up(1) || MinigameInputHelper.IsButton1Up(2) || MinigameInputHelper.IsButton2Up(1) || MinigameInputHelper.IsButton2Up(2)) { if (selected == 3) { LoadMainMenu(); return; } if (selected == 0) { LevelState.beatMapFilename = "Tempo/Beatmaps/Easy"; LevelState.songFilename = "Tempo/Songs/Easy"; } else if (selected == 1) { LevelState.beatMapFilename = "Tempo/Beatmaps/Intermediate"; LevelState.songFilename = "Tempo/Songs/Intermediate"; } else if (selected == 2) { LevelState.beatMapFilename = "Tempo/Beatmaps/Expert"; LevelState.songFilename = "Tempo/Songs/Expert"; } else if (selected == 4) { LevelState.beatMapFilename = "Tempo/Beatmaps/Click Track"; LevelState.songFilename = "Tempo/Songs/Click Track"; } PlayGame(); } if (coolDown <= 0) { // are one or more of the joysticks being pushed float joystick1 = MinigameInputHelper.GetVerticalAxis(1); float joystick2 = MinigameInputHelper.GetVerticalAxis(2); bool joystick_up = joystick1 > 0 || joystick2 > 0; bool joystick_down = joystick1 < 0 || joystick2 < 0; if (joystick_up) { selected = (selected + 4) % 5; coolDown = 0.3f; } else if (joystick_down) { selected = (selected + 1) % 5; coolDown = 0.3f; } myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(null); buttons[selected].GetComponent <Button>().Select(); } else if (coolDown > 0) { coolDown -= Time.deltaTime; } }
void FixedUpdate() { float moveHorizontal = MinigameInputHelper.GetHorizontalAxis(player_num); float moveVertical = MinigameInputHelper.GetVerticalAxis(player_num); Vector3 movement = Vector3.Normalize(new Vector3(moveHorizontal, 0.0f, moveVertical)); anim.SetFloat("Speed", 0); //when tongue is not moving, you can run and jump freely // if (!tongue.moving) { tonguePos = transform.position; if (movement.magnitude > 0.1) { rb.MovePosition(transform.position + movement * horizontalSpeed); Quaternion q = Quaternion.LookRotation(-1 * movement, Vector3.up); if (!anim.GetCurrentAnimatorStateInfo(0).IsName("Ghost_Armature|TongueOut")) { rb.MoveRotation(q); } facingDirection = Vector3.Normalize(movement); anim.SetFloat("Speed", moveHorizontal * moveHorizontal + moveVertical * moveVertical); } if (grounded && MinigameInputHelper.IsButton1Held(player_num)) { anim.SetBool("Grounded", false); anim.SetTrigger("Jump"); audio.PlayOneShot(jumpingSound, 1.0F); grounded = false; rb.AddForce(Vector3.up * jumpPower); } else { anim.ResetTrigger("Jump"); } if (!grounded && rb.transform.position.y < .01) { grounded = true; anim.SetBool("Grounded", true); } if (!grounded) { rb.AddForce(Vector3.down * fallPower); } if (MinigameInputHelper.IsButton2Held(player_num) && !tongue.moving) { anim.SetTrigger("Tongue"); audio.PlayOneShot(tongueSound, 1.0F); tongue.setDestination(transform.position + facingDirection * tongueDistance); } else { anim.ResetTrigger("Tongue"); } } // //move fruits being eaten closer to the mouth // foreach(GameObject fruit in eating) // { // if (fruit != null) // { // Vector3 newPos = Vector3.Lerp(fruit.transform.position, mouth.position, eatingSpeed * Time.deltaTime); // fruit.transform.position = new Vector3(newPos.x, fruit.transform.position.y, newPos.z); // } // } }
// 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; }