Beispiel #1
0
    public override void Destroy()
    {
        gameObject.layer = LayerMask.NameToLayer("Scenario");
        explosionRadius.UpdateColliders();
        for (int i = 0; i < explosionRadius.Colliders.Length; i++)
        {
            if (explosionRadius.Colliders [i] != null)
            {
                ExplosionCrate explosionCrate = explosionRadius.Colliders [i].gameObject.GetComponent <ExplosionCrate> ();


                if (explosionCrate != null)
                {
                    explosionCrate.OnExplode(0.2f);
                }
                else
                {
                    IHittable hittable = explosionRadius.Colliders [i].gameObject.GetComponent <IHittable> ();
                    if (hittable != null)
                    {
                        hittable.OnThrowAway();
                        hittable.OnHit(transform.position);
                    }
                }
            }
        }

        Destroy(gameObject);
    }
Beispiel #2
0
    void OnTriggerEnter(Collider other)
    {
        ExplosionCrate explosionCrate = other.gameObject.GetComponent <ExplosionCrate> ();

        if (explosionCrate != null)
        {
            explosionCrate.Destroy();
            Destroy();
        }
    }