Пример #1
0
        void OnCollisionEnter2D(Collision2D collision)
        {
            if (collision.transform.gameObject == this.Player)
            {
                Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider);
            }

            string tag = collision.collider.tag;

            if (tag == "TerrainObject")
            {
                Physics2D.IgnoreCollision(GetComponent <BoxCollider2D>(), collision.collider);
                Terrain2 t   = collision.gameObject.GetComponent <Terrain2>();
                float    tmp = destructionCircle.radius;
                destructionCircle.radius = radius;
                t.DestroyGround(destructionCircle);
                destructionCircle.radius = tmp;
            }
            else if (tag.Contains("Player"))
            {
                int          id     = collision.collider.gameObject.GetInstanceID();
                GameObject[] totems = GameObject.FindGameObjectsWithTag(tag.Replace("Module", ""));
                foreach (GameObject g in totems)
                {
                    Totem totem = g.GetComponent <Totem>();
                    foreach (GameObject mod in totem.Modulos)
                    {
                        if (mod.GetInstanceID() == id)
                        {
                            if (totem.IgluActivado() && (mod.GetInstanceID() == totem.GetIDModuloProtegidoIglu()))
                            {
                                Iglu ig = totem.GetComponentInChildren <Iglu>();
                                ig.IncNumeroUsos();
                                Destroy(this.gameObject);
                            }
                            else
                            {
                                totem.SendMessage("Damage", new HealthEvent(gameObject, damage));
                                totem.DecreaseVida();
                            }
                        }
                    }
                }
            }

            GameObject executeDeathExplosion = Instantiate(this.explosion, this.gameObject.transform.position, this.explosion.transform.rotation);

            Destroy(executeDeathExplosion, executeDeathExplosion.GetComponent <AudioSource>().clip.length);

            Destroy(this.gameObject);
        }
Пример #2
0
        void Explosion()
        {
            Terrain2 t = this.collision.gameObject.GetComponent <Terrain2>();

            if (t != null)
            {
                destructionCircle.radius = radius;
                t.DestroyGround(destructionCircle);
            }
            GameObject executeDeathExplosion = Instantiate(this.explosion, this.gameObject.transform.position, this.explosion.transform.rotation);

            Destroy(executeDeathExplosion, executeDeathExplosion.GetComponent <AudioSource>().clip.length);
            Destroy(this.gameObject);
        }
Пример #3
0
        void Explosion()
        {
            /*Vector3 explosionPos = this.transform.position;
             * Collider[] colliders = Physics.OverlapSphere(explosionPos, radius);
             * foreach (Collider hit in colliders)
             * {
             *  Rigidbody2D rb = hit.GetComponent<Rigidbody2D>();
             *  if (rb != null)
             *      rb.AddForce(explosionPos, ForceMode2D.Impulse);
             * }*/
            Terrain2 t = this.collision.gameObject.GetComponent <Terrain2>();

            if (t != null)
            {
                destructionCircle.radius = radius;
                t.DestroyGround(destructionCircle);
            }
            GameObject executeDeathExplosion = Instantiate(this.explosion, this.gameObject.transform.position, this.explosion.transform.rotation);

            Destroy(executeDeathExplosion, executeDeathExplosion.GetComponent <AudioSource>().clip.length);
            Destroy(this.gameObject);
        }