예제 #1
0
    IEnumerator FinishAttack(Explodable explodable, LaserBeam leftBeam, LaserBeam rightBeam)
    {
        yield return(new WaitForSeconds(m_attackDuration));

        Destroy(leftBeam.gameObject);
        Destroy(rightBeam.gameObject);

        explodable.Explode();
    }
 public void Interact(ControlledBehaviour controlled)
 {
     if (controlled.CanBreak && !_exploded)
     {
         _exploded = true;
         _explodable.Explode(transform.GetChild((0)));
         Destroy(gameObject, 0.5f);
     }
 }
예제 #3
0
    void OnTriggerEnter(Collider other)
    {
        Explodable explodable = other.gameObject.GetComponent <Explodable>();

        if (explodable)
        {
            explodable.Explode();
            Destroy(gameObject);
        }
    }
예제 #4
0
    public IEnumerator ShowExplosion(Vector3 pos, Quaternion rotation, Explodable expl, float delay)
    {
        yield return(new WaitForSeconds(delay));

        if (expl.DoShowIndirectExplosions())
        {
            Instantiate(explosion, pos, rotation);
        }
        // explode it for real
        expl.Explode(this, BarrelExplosionPwr);
    }
예제 #5
0
 void Execute()
 {
     GameObject[] selection = Selection.gameObjects;
     foreach (GameObject obj in selection)
     {
         Explodable explodable = obj.GetComponent <Explodable>();
         if (explodable != null)
         {
             explodable.Explode();
         }
     }
 }
예제 #6
0
    public void Explode(object other, float pwr)
    {
        print("Vibrate!");
        // Handheld.Vibrate();
        GameObject.Destroy(this.gameObject);
        if (other is Explodable)
        {
            Explodable e = other as Explodable;

            // check if its not a bullet as it will explode on its own
            if (!e.GetTag().Equals(GetTag()))
            {
                e.Explode(this, pwr);
            }
            else
            {
                // handle bullet double explosion, make sure only one explodes
                if (GetHashCode() > e.GetHashCode())
                {
                    GameObject.Instantiate(explosion, transform.position, transform.rotation);
                }

                return;
            }
        }

        // blow up the rest of the things
        if (ranger.Objects.Count != 0)
        {
            // blow those guys up aswell
            for (var i = 0; i < ranger.Objects.Count; i++)
            {
                GameObject o = (GameObject)ranger.Objects[i];
                // trigger explosion if explodable
                var e = o.GetComponent(typeof(Explodable)) as Explodable;
                if (e != null && e != other)
                {
                    // explode it
                    e.Explode(this, pwr);
                    if (e.DoShowIndirectExplosions())
                    {
                        GameObject.Instantiate(explosion, o.transform.position, o.transform.rotation);
                    }
                }
                else if (e != other)
                {
                    // show explosions
                    GameObject.Instantiate(explosion, o.transform.position, o.transform.rotation);
                }
            }
        }

        if (other is Explodable && !(other as Explodable).DoShowExplosion())
        {
            // do nothing
        }
        else
        {
            GameObject.Instantiate(explosion, transform.position, transform.rotation);
        }
    }