Exemplo n.º 1
0
    private IEnumerator FadeOutAndDelete(GameObject o, float destroyTime)
    {
        yield return new WaitForSeconds(destroyTime);

        ObjectFader objectFader = o.GetComponent<ObjectFader>();
        if (!objectFader)
        {
            Destroy(o);
        }
        else
        {
            objectFader.OnFadeToTransparentComplete += () => Destroy(o);
            objectFader.FadeToTransparent();
        }
    }
Exemplo n.º 2
0
    private void BreakOnHit()
    {
        GameObject instantiatedBrokenVersion = Instantiate(brokenVersion, transform.position, transform.rotation);

        OnBreak?.Invoke(instantiatedBrokenVersion);

        if (fadeAwayAfterBreaking)
        {
            ObjectFader objectFader = instantiatedBrokenVersion.GetComponent <ObjectFader>();
            if (objectFader)
            {
                objectFader.FadeToTransparent(secondsLater: destroyInSeconds, destroyAfter: true);
            }
        }

        Rigidbody[] rigidbodies = instantiatedBrokenVersion.GetComponentsInChildren <Rigidbody>();
        foreach (Rigidbody r in rigidbodies)
        {
            r.AddExplosionForce(explosionForce, transform.position, 1f);
        }
        Destroy(gameObject);
    }
Exemplo n.º 3
0
    private void OnCollisionEnter(Collision other)
    {
        if (!hasBeenBumped || hasHit || other.gameObject.CompareTag("Player"))
        {
            return;
        }

        noisePing.SpawnNoisePing(other);
        hasHit = true;

        UIManager.Instance.staminaBar.InstantIncreaseAwakenessBy(awakenessIncreasePercentage);

        OnHit?.Invoke();

        if (fadeAndDestroyAfterThrow)
        {
            ObjectFader objectFader = GetComponent <ObjectFader>();
            if (objectFader)
            {
                objectFader.FadeToTransparent(destroyAfterSeconds, fadeAndDestroyAfterThrow);
            }
        }
    }