Ejemplo n.º 1
0
    void updateFasten()
    {
        if (Input.GetKey(KeyCode.DownArrow) && (fastening || getRotation() >= maxRotation || Mathf.Approximately(getRotation(), maxRotation)))
        {
            fastening = true;
            float diff = downSpeed * Time.deltaTime;
            if (getRotation() - diff <= minRotation)
            {
                goingUp = false;
                setRotation(minRotation);
                if (cyclesLeft == 1)
                {
                    finish();
                    return;
                }
                else if (arrowIndicator)
                {
                    arrowBlink.enableBlink(true);
                }
            }
            else
            {
                setRotation(getRotation() - diff);
            }

            setBoltRotation(getRotation() + boltRotation);
        }
        else
        {
            if (Input.GetKey(KeyCode.UpArrow))
            {
                goingUp = true;
            }
            if (goingUp && (!fastening || getRotation() <= minRotation || Mathf.Approximately(getRotation(), minRotation)))
            {
                if (fastening)
                {
                    cyclesLeft--;
                }
                fastening = false;
                float diff = upSpeed * Time.deltaTime;
                if (getRotation() + diff >= maxRotation)
                {
                    arrowBlink.disableBlink(false);
                    setRotation(maxRotation);
                }
                else
                {
                    setRotation(getRotation() + diff);
                }
            }
        }


        handVibrate.vibrateOn         = fastening;
        screw.transform.localPosition = new Vector3(0f, getScrewHeight(), 0f);
    }
Ejemplo n.º 2
0
    void updateFasten()
    {
        if (fastening)
        {
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                if (!moving)
                {
                    _audioSource.PlayOneShot(fastenSound);
                    setRotation(maxRotation);
                }
                moving = true;
            }
            if (moving)
            {
                float diff = downSpeed * Time.deltaTime;
                if (getRotation() - diff <= minRotation)
                {
                    cyclesLeft--;
                    moving    = false;
                    fastening = false;
                    setRotation(minRotation);
                    if (cyclesLeft == 0)
                    {
                        finish();
                        return;
                    }
                    else if (arrowIndicator)
                    {
                        arrowBlink.enableBlink(true);
                    }
                }
                else
                {
                    setRotation(getRotation() - diff);
                }

                setBoltRotation(getRotation() + boltRotation);
            }
            else
            {
                setRotation(maxRotation + updateShake());
                setBoltRotation(maxRotation + boltRotation);
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                moving = true;
            }
            if (moving)
            {
                float diff = upSpeed * Time.deltaTime;
                if (getRotation() + diff >= maxRotation)
                {
                    moving    = false;
                    fastening = true;
                    arrowBlink.disableBlink(false);
                    setRotation(maxRotation);
                }
                else
                {
                    setRotation(getRotation() + diff);
                }
            }
        }


        //handVibrate.vibrateOn = fastening;
        screw.transform.localPosition = new Vector3(0f, getScrewHeight(), 0f);
    }