Ejemplo n.º 1
0
    public void Explode(object caller, float pwr) /* pwr is insignifact to us */
    {
        // create large explosion
        GameObject o = Instantiate(explosion, transform.position + new Vector3(0.5f, -0.5f), transform.rotation) as GameObject;

        o.transform.localScale = new Vector3(3f, 3f, 1f);
        o.gameObject.GetComponentInChildren <PointEffector2D>().forceMagnitude *= 2f;
        o.gameObject.GetComponent <PostAnimDestruct>().EffectorDestroyDelay    *= 3f;

        // affect any one in area of explosion using the circle collider
        Collider2D[] objects = colliders.ToArray();
        if (objects != null && objects.Length > 0)
        {
            for (int i = 0; i < objects.Length; i++)
            {
                Collider2D other = objects[i];
                if (other != null && other.gameObject != null)
                {
                    Explodable expl = other.gameObject.GetComponent(typeof(Explodable)) as Explodable;
                    if (expl != null)
                    {
                        // show an explosion at that point
                        expl.GetMono().StartCoroutine(ShowExplosion(other.transform.position, other.transform.rotation, expl, 0.1f));
                    }
                }
                else
                {
                    // remove from list
                    OnTriggerExit2D(other);
                }
            }
        }

        gameObject.SetActive(false);
        // destroy self after 3 seconds
        Destroy(gameObject, 3f);
    }