Beispiel #1
0
        void MaybeDestroy(Rigidbody rb, Rigidbody other = null)
        {
            var val = 0f;

            if (rb != null)
            {
                val = NeodroidUtilities.KineticEnergy(rb);
            }

            var val_other = 0f;

            if (other != null)
            {
                val_other = NeodroidUtilities.KineticEnergy(rb);
            }

            if (this.Debugging)
            {
                Debug.Log($"{val} {val_other}");
            }

            if ((val >= this._Threshold || val_other >= this._Threshold) && !this._has_exploded)
            {
                this._Actor.Kill();
                this._has_exploded = true;

                /*if (this._explosion_particle_system) {
                 * this._explosion_particle_system.Play();
                 * this._delay = this._explosion_particle_system.main.duration;
                 * }*/

                this.StartCoroutine(
                    this.SpawnBroken(
                        this._delay,
                        this._Rigidbody.transform.parent,
                        this._Rigidbody.transform.position,
                        this._Rigidbody.transform.rotation,
                        this._Rigidbody.velocity,
                        this._Rigidbody.angularVelocity));
                this._Rigidbody.gameObject.SetActive(false);
                this._Rigidbody.Sleep();
            }
        }
Beispiel #2
0
        void De(Rigidbody rb, Rigidbody other = null)
        {
            var val = 0f;

            if (rb != null)
            {
                val = NeodroidUtilities.KineticEnergy(rb);
            }
            var val_other = 0f;

            if (other != null)
            {
                val_other = NeodroidUtilities.KineticEnergy(rb);
            }
            if (this.Debugging)
            {
                print(string.Format("{0} {1}", val, val_other));
            }
            if ((val >= this._threshold || val_other >= this._threshold) && !this._has_exploded)
            {
                this._actor.Kill();
                this._has_exploded = true;
                if (this._explosion)
                {
                    this._explosion.Play();
                    this._delay = this._explosion.main.duration;
                }

                this.StartCoroutine(
                    this.SpawnBroken(
                        this._delay,
                        this._rigidbody.transform.parent,
                        this._rigidbody.transform.position,
                        this._rigidbody.transform.rotation,
                        this._rigidbody.velocity,
                        this._rigidbody.angularVelocity));
                this._rigidbody.gameObject.SetActive(false);
                this._rigidbody.Sleep();
            }
        }