private void checkForInput()
        {
            if (Mathf.Abs(MinigameInputHelper.GetHorizontalAxis(1)) < 1)
            {
                recentlyMoved = false;
            }

            if (!recentlyMoved && MinigameInputHelper.GetHorizontalAxis(1) == 1)
            {
                frets[currentFret].deselectFret();
                currentFret = (currentFret + 1) % 4;
                frets[currentFret].selectFret();
                recentlyMoved = true;
            }

            else if (!recentlyMoved && MinigameInputHelper.GetHorizontalAxis(1) == -1)
            {
                frets[currentFret].deselectFret();
                currentFret = (currentFret + 3) % 4;
                frets[currentFret].selectFret();
                recentlyMoved = true;
            }

            if (recentlyPressed && (Time.time - lastBtnPress >= 0.03f))
            {
                // double press timer elapsed, single press is registered
                processScore(frets[currentFret].strumFret(false));
                recentlyPressed = false;
            }

            bool button1 = MinigameInputHelper.IsButton1Down(1);
            bool button2 = MinigameInputHelper.IsButton2Down(1);

            if (button1 || button2)
            {
                // both buttons pressed at exact same frame
                if (button1 && button2)
                {
                    processScore(frets[currentFret].strumFret(true));
                }

                // if no recent button press, set up double press timer
                else if (!recentlyPressed)
                {
                    recentlyPressed = true;
                    lastBtnPress    = Time.time;
                }

                // there was recent button press, and another press came within double press timer
                else if (Time.time - lastBtnPress < 0.05f)
                {
                    processScore(frets[currentFret].strumFret(true));
                    recentlyPressed = false;
                }
            }
        }
Пример #2
0
        // Update is called once per frame
        void Update()
        {
            if (MinigameInputHelper.IsButton1Down(2) && laneNumber > 3)
            {
                laneNumber         -= 1;
                transform.position -= movement;
            }

            if (MinigameInputHelper.IsButton2Down(2) && laneNumber < 5)
            {
                laneNumber         += 1;
                transform.position += movement;
            }
        }
    // 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;
        }
    }
Пример #4
0
        // 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);
                }
            }
        }
Пример #5
0
        // Update is called once per frame
        void Update()
        {
            MovePaddle();

            if (MinigameInputHelper.IsButton1Down(playerNumber))
            {
                leftFlipper.GetComponent <PinballPongFlipper>().Flip();
            }
            if (MinigameInputHelper.IsButton1Up(playerNumber))
            {
                leftFlipper.GetComponent <PinballPongFlipper>().UnFlip();
            }
            if (MinigameInputHelper.IsButton2Down(playerNumber))
            {
                rightFlipper.GetComponent <PinballPongFlipper>().Flip();
            }
            if (MinigameInputHelper.IsButton2Up(playerNumber))
            {
                rightFlipper.GetComponent <PinballPongFlipper>().UnFlip();
            }
        }
Пример #6
0
    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);
    }
Пример #7
0
        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);
            }
        }
Пример #9
0
        void Update()
        {
            if (direction)
            {
                spriteRenderer.flipX = false;
            }
            else
            {
                spriteRenderer.flipX = true;
            }
            float horizontal_axis = MinigameInputHelper.GetHorizontalAxis(player + 1);
            bool  button1         = MinigameInputHelper.IsButton1Down(player + 1);
            bool  button2         = MinigameInputHelper.IsButton2Down(player + 1);
            bool  button2Up       = MinigameInputHelper.IsButton2Up(player + 1);
            float pos_x           = gameObject.transform.position.x;
            float pos_y           = gameObject.transform.position.y;
            float o_pos_x         = other.transform.position.x;
            float o_pos_y         = other.transform.position.y;
            //double p1_height = this.GetComponent<MoveScript>().playerHeight;
            double p1_width = 0.6 * this.GetComponent <MoveScript>().playerWidth;

            time += Time.deltaTime;
            if (horizontal_axis < -0.1)
            {
                direction = true;                                     //left
            }
            else if (horizontal_axis > 0.1)
            {
                direction = false;                                         //right
            }
            if ((button1 || MinigameInputHelper.IsButton1Held(player + 1)) && time >= cooldown && TYPE != 4 && ballCharge < 30)
            {
                ballCharge++;
            }

            if (MinigameInputHelper.IsButton1Up(player + 1) && time >= cooldown && ballCharge > 0 && TYPE != 4)
            {
                if (player == 0)
                {
                    animator.Play("Attack");
                }
                else
                {
                    animator.Play("Attack2");
                }
                //animator.SetInteger("state", 3 + TYPE);
                attacktime = 0;
                time       = 0;
                GameObject p;
                attacktime = 0;
                if (direction && !gameObject.GetComponent <ActionScript>().defenseOn)
                {
                    p = Instantiate(projectile, transform.position - new Vector3((float)2, -1, 0), transform.rotation);
                    p.GetComponent <Rigidbody2D>().velocity = new Vector2(-2.5f, 1.0f) * ballCharge;
                }
                else if (!gameObject.GetComponent <ActionScript>().defenseOn)
                {
                    p = Instantiate(projectile, transform.position + new Vector3((float)2, 1, 0), transform.rotation);
                    p.GetComponent <Rigidbody2D>().velocity = new Vector2(2.5f, 1.0f) * ballCharge;
                }
                ballCharge = 0;
            }

            //if(attacktime > 0.5 && animator.GetInteger("state") == 3 + TYPE) animator.SetInteger("state", 0 + TYPE);

            if (button1 && time >= cooldown && TYPE != 0)             //kick
            {
                double xdist = gameObject.transform.position.x - other.transform.position.x;

                /*if (!direction && ((pos_x < 0 && xdist > 0 && xdist < 2) ||
                 * (pos_x > 0 && xdist < 0 && xdist > -2)) &&
                 * other.GetComponent<ActionScript>().defenseOn)
                 * {
                 * other.GetComponent<ActionScript>().shieldHits = other.GetComponent<ActionScript>().shieldHits + 1;
                 * }*/
                time = 0;
                if (player == 0)
                {
                    animator.Play("K_Attack");
                }
                else
                {
                    animator.Play("Attack_K2");
                }
                if (direction && xdist > 0 && xdist < 3 * p1_width)                /*((pos_x < 0 && xdist > 0 && xdist < 2*p1_width) ||
                                                                                    * (pos_x > 0 && xdist < 0 && xdist > -2*p1_width)))*/
                {
                    if (!other.GetComponent <ActionScript>().defenseOn)
                    {
                        gameObject.GetComponent <HealthScript>().TakeDamage(1);
                        Debug.Log("reached here");
                    }
                    else
                    {
                        other.GetComponent <ActionScript>().shieldHits++;
                        other.GetComponent <Renderer>().material.SetColor("_Color", Color.blue);
                        Debug.Log(shieldHits);

                        /*if (shieldHits >= 3)
                         * {
                         * shield.transform.localScale = new Vector3(0, 0, 0);
                         * defenseOn = false;
                         * shieldHits = 0;
                         * defCooldown = 0;
                         * }*/
                    }
                }

                /*if (direction && ((pos_x < 0 && xdist < 0 && xdist > -2) ||
                 * (pos_x > 0 && xdist > 0 && xdist < 2)) &&
                 * other.GetComponent<ActionScript>().defenseOn)
                 * {
                 * other.GetComponent<ActionScript>().shieldHits++;
                 * }*/
                if (!direction && xdist < 0 && xdist > -3 * p1_width)                /*((pos_x < 0 && xdist < 0 && xdist > -2*p1_width) ||
                                                                                      * (pos_x > 0 && xdist > 0 && xdist < 2*p1_width)))*/
                {
                    if (!other.GetComponent <ActionScript>().defenseOn)
                    {
                        gameObject.GetComponent <HealthScript>().TakeDamage(1);
                        Debug.Log("reached here");
                    }
                    else
                    {
                        other.GetComponent <ActionScript>().shieldHits++;
                        other.GetComponent <Renderer>().material.SetColor("_Color", Color.blue);
                        Debug.Log(shieldHits);

                        /*if (shieldHits >= 3)
                         * {
                         * shield.transform.localScale = new Vector3(0, 0, 0);
                         * defenseOn = false;
                         * shieldHits = 0;
                         * defCooldown = 0;
                         * }*/
                    }
                }
            }

            /*if (button1 && TYPE != 0) {
             * Debug.Log("karate attack");
             *
             * //animator.SetInteger("state", 3 + TYPE);
             * Debug.Log(animator.GetInteger("state"));
             * attacktime = 0;
             * }
             * /*dif (button1 && time >= cooldown && TYPE != 0 && !other.GetComponent<ActionScript>().defenseOn){//punch //IS THERE A SHIELD CHECK HERE?? yes!
             * double xdist = pos_x - o_pos_x;
             * if (!direction && ((pos_x < 0 && xdist > 0 && xdist < 2*p1_width) ||
             *      (pos_x > 0 && xdist < 0 && xdist > -2*p1_width)))
             * {
             *      gameObject.GetComponent<HealthScript>().TakeDamage(1);
             * }
             * if (direction && ((pos_x < 0 && xdist < 0 && xdist > -2*p1_width) ||
             *      (pos_x > 0 && xdist > 0 && xdist < 2*p1_width)))
             * {
             *      gameObject.GetComponent<HealthScript>().TakeDamage(1);
             * }
             * }*/
            defCooldown += Time.deltaTime;
            if (defCooldown > 3 && !defenseOn)
            {
                GameObject.Find("shieldready" + player).transform.localScale = new Vector3(1, 1, 1);
            }
            else
            {
                GameObject.Find("shieldready" + player).transform.localScale = new Vector3(0, 0, 0);
            }
            if (button2 && TYPE != 8 && defCooldown > 3)
            {
                shield.transform.localScale = new Vector3(1, 1, 1);
                defenseOn   = true;
                defCooldown = 0;
            }
            if (shieldHits >= 3)
            {
                shield.transform.localScale = new Vector3(0, 0, 0);
                defenseOn   = false;
                shieldHits  = 0;
                defCooldown = 0;
            }
            if (button2Up)
            {
                shield.transform.localScale = new Vector3(0, 0, 0);
                defenseOn = false;
            }
            attacktime += Time.deltaTime;
        }
Пример #10
0
        // 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;
        }