Exemplo n.º 1
0
        private void OnDestroyed(Destructable destructable)
        {
            IsDestroyed    = true;
            _stats.Points += _points;

            var go            = (GameObject)Instantiate(_destroyedObject, transform.position, Quaternion.identity);
            var destroyScript = go.GetComponent <DestroyAfterTime>();

            if (destroyScript.IsNotNull())
            {
                destroyScript.ShouldDestroy = true;
            }
            if (_svgRenderer.IsNotNull())
            {
                _fadeTween.SafelyAbort();
                _fadeTween = _svgRenderer.TweenColor()
                             .To(ColorUtils.Colors.Translucent, _fadeSettings)
                             .OnComplete(
                    () => {
                    Destroy(gameObject);
                }
                    )
                             .Start();
            }
            else if (_spriteRenderer.IsNotNull())
            {
                _fadeTween.SafelyAbort();
                _fadeTween = _spriteRenderer.TweenColor()
                             .To(ColorUtils.Colors.Translucent, _fadeSettings)
                             .OnComplete(
                    () => {
                    Destroy(gameObject);
                }
                    )
                             .Start();
            }
            else
            {
                Destroy(gameObject);
            }
        }
Exemplo n.º 2
0
 private void DestructableOnDestroyed(Destructable destructable)
 {
     _destructablesInRange.Remove(destructable);
     destructable.Destroyed -= DestructableOnDestroyed;
 }