Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0) && location.Contains(Input.mousePosition) && hasAnimated == false)
        {
            currentAnimationTime = 0;
            isAnimating          = true;
            hasAnimated          = true;
            showScrew();
            if (GetComponent <AudioSource>() != null)
            {
                GetComponent <AudioSource>().clip = soundclip.MakeSubclip(audioStartTime, audioEndTime);
                GetComponent <AudioSource>().Play();
            }
        }
        if (currentAnimationTime < AnimationTime)
        {
            float currentRot = ((currentAnimationTime / AnimationTime) * Revolutions) * 360;
            transform.GetChild(1).rotation = Quaternion.Euler(0, 0, currentRot);
            currentAnimationTime          += Time.deltaTime;
        }
        else if (isAnimating)
        {
            isAnimating = false;

            float currentRot = Revolutions * 360;
            transform.GetChild(1).rotation = Quaternion.Euler(0, 0, currentRot);
            currentAnimationTime          += Time.deltaTime;
            afterEvent?.Invoke();
        }
    }
Example #2
0
 // Update is called once per frame
 public void Increment()
 {
     time += Click;
     if (GetComponent <AudioSource>() != null)
     {
         GetComponent <AudioSource>().clip = clickSound.MakeSubclip(audioStartTime, audioEndTime);
         GetComponent <AudioSource>().Play();
     }
 }
Example #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && mouseOnSpring())
        {
            scale = scale - clickAmount;
            GetComponent <AudioSource>().clip = sound.MakeSubclip(startTime, stopTime);
            GetComponent <AudioSource>().Play();
        }
        scale = scale + K * (1 - scale) * (1 - scale) * Mathf.Sign(1 - scale) * Time.deltaTime;



        if (scale < minimum)
        {
            scale  = 0;
            isDone = true;
        }
        scale = scale < 0 ? 0 : scale;
        renderSpring();
    }