示例#1
0
    public void Explode()
    {
        if (!this.m_triggered)
        {
            this.m_triggered = true;
            Collider[] array = Physics.OverlapSphere(base.transform.position, this.m_explosionRadius);
            foreach (Collider collider in array)
            {
                GameObject gameObject = this.FindParentWithRigidBody(collider.gameObject);
                if (gameObject != null)
                {
                    int num = this.CountChildColliders(gameObject, 0);
                    this.AddExplosionForce(gameObject, 1f / (float)num);
                }
                TNT component = collider.GetComponent <TNT>();
                if (component)
                {
                    component.Explode();
                }
            }
            WPFMonoBehaviour.effectManager.CreateParticles(this.m_smokeCloud, base.transform.position - Vector3.forward * 12f, true);
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.tntExplosion, base.transform.position);

            base.StartCoroutine(this.ShineLight());
            if (this.OnExplosion != null)
            {
                this.OnExplosion();
            }
        }
    }
示例#2
0
文件: TNT.cs 项目: mrdivdiz/bpvita
    public virtual void Explode()
    {
        if (!this.m_triggered)
        {
            this.m_triggered = true;
            base.contraption.ChangeOneShotPartAmount(this.m_partType, this.EffectDirection(), -1);
            Collider[] array = Physics.OverlapSphere(base.transform.position, this.m_explosionRadius);
            foreach (Collider collider in array)
            {
                GameObject gameObject = this.FindParentWithRigidBody(collider.gameObject);
                if (gameObject != null)
                {
                    int num = this.CountChildColliders(gameObject, 0);
                    this.AddExplosionForce(gameObject, 1f / (float)num);
                }
                TNT component = collider.GetComponent <TNT>();
                if (component && !(component is AlienTNT))
                {
                    component.Explode();
                }
            }
            Singleton <AudioManager> .Instance.SpawnOneShotEffect(WPFMonoBehaviour.gameData.commonAudioCollection.tntExplosion, base.transform.position);

            WPFMonoBehaviour.effectManager.CreateParticles(this.smokeCloud, base.transform.position - Vector3.forward * 5f, true);
            if (this.extraEffect)
            {
                WPFMonoBehaviour.effectManager.CreateParticles(this.extraEffect, base.transform.position - Vector3.forward * 4f, true);
            }
            this.CheckForTNTAchievement();
            base.contraption.RemovePart(this);
            List <Joint> list = base.contraption.FindPartFixedJoints(this);
            if (list.Count > 0)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    bool flag  = list[j].gameObject == this || list[j].connectedBody == this;
                    bool flag2 = float.IsInfinity(list[j].breakForce);
                    if (!flag2 || flag)
                    {
                        UnityEngine.Object.Destroy(list[j]);
                    }
                }
                base.HandleJointBreak(float.MaxValue, true);
            }
            base.StartCoroutine(this.ShineLight());
        }
    }
示例#3
0
    void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Player")
        {
            if (!detonated)
            {
                triggered = trigger.returnTrigger();

                if (!triggered)
                {
                    if (isOculus)
                    {
                        oculus.SetActive(false);
                    }
                    camera3.enabled = false;
                    camera1.enabled = false;
                    camera2.enabled = true;
                    print("not triggered");
                }
                if (triggered)
                {
                    if (isOculus)
                    {
                        oculus.SetActive(false);
                    }
                    camera3.enabled = true;
                    camera1.enabled = false;
                    camera2.enabled = false;
                    print("triggered");
                }

                bomb.gameObject.GetComponent <AudioSource>().Play();
                //yield return WaitForSeconds(1);
                Time.timeScale      = 0.5F;
                Time.fixedDeltaTime = 0.5F * 0.02F;
                bomb.Explode();
                detonated = true;
                countDown = true;
            }
        }
    }