Exemple #1
0
        void Update()
        {
            if (fading)
            {
                currentFadeTime += Time.deltaTime;
                Renderer.color   = Color.Lerp(FromColor, ToColor, currentFadeTime / Duration);
                if (currentFadeTime >= Duration)
                {
                    fading         = false;
                    Renderer.color = ToColor;
                    DoneBehaviour.DoneWithObject(this);

                    /*switch (DoneBehaviour)
                     * {
                     *      case OnDoneBehaviour.Disable:
                     *              gameObject.SetActive(false);
                     *              break;
                     *      case OnDoneBehaviour.DestroyOrPool:
                     *              var poolableObject = GetComponent<PoolableObject>();
                     *              if (poolableObject != null)
                     *              {
                     *                      poolableObject.ReturnToPool();
                     *                      break;
                     *              }
                     *              else
                     *              {
                     *                      goto case OnDoneBehaviour.Destroy;
                     *              }
                     *      case OnDoneBehaviour.Destroy:
                     *              Destroy(gameObject);
                     *              break;
                     * }*/
                }
            }
        }
Exemple #2
0
        //bool callbackAdded = false;

        protected virtual void OnEnable()
        {
            if (autoPlay && AnimationData.HasClip(autoPlayClip))
            {
                PlayAnimation(autoPlayClip);
                onAnimationDone += s => OnClipFinish.DoneWithObject(this);
            }
        }
Exemple #3
0
        IEnumerator MainRoutine()
        {
            for (float idleTimer = 0; idleTimer < idleTime && !collided; idleTimer += Time.deltaTime)
            {
                FaceAngle();
                ProjectileSquash();
                yield return(null);
            }

            if (!collided)
            {
                Impact();
            }

            float animTimer = 0f;
            int   frame     = 0;

            while (frame < sprites.GetLength(0))
            {
                animTimer += Time.deltaTime;
                if (animTimer >= (1f / fps))
                {
                    animTimer -= (1f / fps);
                    frame++;
                    if (frame < sprites.GetLength(0))
                    {
                        spriteRenderer.sprite = sprites[frame];
                    }
                    else
                    {
                        WhenDone.DoneWithObject(this);

                        /*switch (WhenDone)
                         * {
                         *      case OnDoneBehaviour.Disable:
                         *              gameObject.SetActive(false);
                         *              break;
                         *      case OnDoneBehaviour.DestroyOrPool:
                         *              var pool = GetComponent<PoolableObject>();
                         *              if (pool != null)
                         *              {
                         *                      pool.ReturnToPool();
                         *              }
                         *              else
                         *              {
                         *                      goto case OnDoneBehaviour.Destroy;
                         *              }
                         *              break;
                         *      case OnDoneBehaviour.Destroy:
                         *              Destroy(gameObject);
                         *              break;
                         * }*/
                    }
                }
            }
        }
Exemple #4
0
        void Update()
        {
            timer += Time.deltaTime * accel;
            UpdateVisuals();
            if (timer > 1f)
            {
                doneBehaviour.DoneWithObject(this);

                /*if (poolable != null)
                 * {
                 *      poolable.ReturnToPool();
                 * }
                 * else
                 * {
                 *      Destroy(gameObject);
                 * }*/
            }
        }
    IEnumerator Destroyer()
    {
        yield return(new WaitForSeconds(lifetime));

        doneBehaviour.DoneWithObject(this);
    }