Beispiel #1
0
 // If inflated, begin the countdown. When it reaches zero, set inflated to false and return the object to it's
 // normal size. Turn off the power of the battery script to ensure it will glow when the mouse it over it again.
 private void LateUpdate()
 {
     anim.SetBool("puffed", inflated);
     if (inflated)
     {
         if (easeTimer < 1)
         {
             easeTimer           += 2 * Time.deltaTime;
             easeTimer            = Mathf.Min(easeTimer, 1);
             transform.localScale = Vector3.one * EasingFunction.EaseOutElastic(initialSize, inflatedSize, easeTimer);
         }
         timer -= Time.deltaTime;
         if (timer <= 0)
         {
             inflated = false;
             anim.SetBool("puffed", false);
             bat.PowerOff();
         }
     }
     else if (easeTimer > 0)
     {
         easeTimer           -= Time.deltaTime;
         easeTimer            = Mathf.Max(easeTimer, 0);
         transform.localScale = Vector3.one * EasingFunction.EaseInElastic(initialSize, inflatedSize, easeTimer);
     }
     if (bat.GetActive())
     {
         Inflate();
         bat.PowerOff();
     }
 }
Beispiel #2
0
    // Using the ClickBattery we can forego keeping our own timer and instead use the cooldown variable from ClickBattery.
    private void Update()
    {
        if (bat.GetActive())
        {
            for (int i = 0; i < poolSize; i++)
            {
                if (cannonballs[i].activeSelf)
                {
                    continue;
                }

                cannonballs[i].transform.position = transform.position + Vector3.forward;
                cannonballs[i].transform.rotation = transform.rotation;
                cannonballs[i].SetActive(true);
                break;
            }
            bat.PowerOff();
        }
    }