Exemplo n.º 1
0
    public void Explode()
    {
        // Disable collision
        if (boxCol != null)
        {
            boxCol.enabled = false;
        }
        if (meshCol != null)
        {
            meshCol.enabled = false;
        }
        if (sphereCol != null)
        {
            sphereCol.enabled = false;
        }
        if (capCol != null)
        {
            capCol.enabled = false;
        }

        explosion = GetComponent <ExplosionForce>();
        if (explosion != null)
        {
            explosion.ExplodeOuter(transform.position);
        }
        if (explosion != null)
        {
            explosion.ExplodeInner(transform.position, nearforce, nearradius, null);
        }

        GameObject explosionEffect = Const.a.GetObjectFromPool(Const.PoolType.GrenadeFragExplosions);

        if (explosionEffect != null)
        {
            explosionEffect.SetActive(true);
            explosionEffect.transform.position = transform.position;
            // TODO: Do I need more than one temporary audio entity for this sort of thing?
            if (deathSound != null)
            {
                GameObject tempAud = GameObject.Find("TemporaryAudio");
                tempAud.transform.position = transform.position;
                AudioSource aS = tempAud.GetComponent <AudioSource>();
                if (aS != null)
                {
                    aS.PlayOneShot(deathSound);
                }
            }
            gameObject.SetActive(false);
        }

        //if (explosionEffect != null) Instantiate(explosion, transform.position, Quaternion.identity); //TODO: use pool
        //Destroy(this.gameObject); //TODO: use pool
    }