Esempio n. 1
0
    void OnGUI()
    {
        if (LogicGlobalFracturing.HelpVisible == false)
        {
            return;
        }

        // Draw global instructions

        LogicGlobalFracturing.GlobalGUI();

        // Draw instructions

        GUILayout.Label("This scene shows:");
        GUILayout.Label("-Voronoi fracturing");
        GUILayout.Label("-Triggered explosion");
        GUILayout.Label("-Collision particles");
        GUILayout.Label("-Collision sounds");
        GUILayout.Label("");
        GUILayout.Label("Press the button below to explode the object.");

        if (GUILayout.Button("Explode"))
        {
            TargetFracturedObject.Explode(TargetFracturedObject.transform.position, ExplosionForce);
        }
    }
    void ExplodeChunks()
    {
        mObject.Explode(transform.position, explodeForce);
        GetComponent <AudioSource>().Play();
        GameObject exp = Instantiate(explosionEffect);

        exp.transform.position = transform.position;
        if (model != null)
        {
            model.SetActive(false);
        }
    }
Esempio n. 3
0
    private void ExplodeAsteroid()
    {
        foreach (var chunk in _chunkList)
        {
            chunk.gameObject.layer = LayerMask.NameToLayer("Chunk");
            chunk.transform.parent = GameManager.Instance.ChunksParent.transform;
        }

        _fracturedObject.Explode(transform.position, GameManager.Instance.AsteroidExplodeForce);
        //StartCoroutine(DestroyMeshColliders());
        StartCoroutine(DestroyChunksAndGameObject());

        Destroy(RadarMesh);
        Destroy(_trailRenderer);
    }
    void OnCollisionEnter(Collision collision)
    {
        if (collision.contacts == null)
        {
            return;
        }

        if (collision.contacts.Length == 0)
        {
            return;
        }

        // Was it a big enough hit?

        FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject>();

        if (fracturedObject != null)
        {
            float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity;

            if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity)
            {
                // Disable fracturable object collider

                fracturedObject.GetComponent <Collider>().enabled = false;

                Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody>();

                if (fracturableRigidbody != null)
                {
                    fracturableRigidbody.isKinematic = true;
                }

                // Enable chunk colliders

                for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++)
                {
                    EnableObjectColliders(fracturedObject.ListFracturedChunks[i].gameObject, true);
                }

                // Explode

                fracturedObject.Explode(collision.contacts[0].point, collision.relativeVelocity.magnitude);
            }
        }
    }
Esempio n. 5
0
    public override void updateLife(Damage d)
    {
        base.updateLife(d);

        if (lifeSlider != null)
        {
            lifeSlider.value = (float)(life) / maxLife;
        }

        if (isDead)
        {
            GetComponent <Collider>().enabled = false;
            FracturedObject f = transform.parent.GetComponentInChildren <FracturedObject>();
            if (f != null)
            {
                //Exploding the fractured object using Ultimate Game Tool fractured object
                f.SupportChunksAreIndestructible = false;
                f.Explode(new Vector3(transform.position.x, 0, transform.position.z), 100f, 100f, false, false, false, false);
            }
            Destroy(this.transform.parent.gameObject);
        }
    }
Esempio n. 6
0
    //private void OnTriggerEnter(Collider c)
    //{
    //    if (c.gameObject.layer == Layers.Asteroid.Index)
    //    {


    //    }
    //}

    #endregion
    #region Methods

    public void TakeDamage()
    {
        Debug.Log("ASteroid hit moon");
        _currentHealth -= DamageAtCollision;

        _changeColor.SetColor((float)_currentHealth / StartHealth);

        if (_currentHealth < 0)
        {
            Outline.SetActive(false);

            foreach (var chunk in _chunkList)
            {
                chunk.gameObject.layer = LayerMask.NameToLayer("Chunk");
                chunk.transform.parent = GameManager.Instance.ChunksParent.transform;
            }

            StartCoroutine("GameOver");

            //GameManager.Instance.IsMoonDestroyed = true;
            _fracturedObject.Explode(transform.position, GameManager.Instance.MoonExplodeForce);
        }
    }
Esempio n. 7
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.contacts == null)
        {
            return;
        }

        if (collision.contacts.Length == 0)
        {
            return;
        }

        // Was it a big enough hit?

        FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject>();

        if (fracturedObject != null)
        {
            float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity;
            //Debug.Log (collision.gameObject.tag.ToString ());충돌체의 tag탐색
            //Debug.Log(collision.gameObject.GetComponent<FracturedObject>().EventDetachMinMass.ToString());
            if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity)
            {
                // Disable fracturable object collider
                if (collision.rigidbody != null)
                {
                    //SendKill (PhotonNetwork.player.ID);
                    fracturedObject.EventDetachMinMass -= collision.rigidbody.mass;
                }
                if (fracturedObject.EventDetachMinMass < 0)
                {
                    //Debug.Log (collision.gameObject.GetComponent<PhotonView> ().ownerId.ToString ());
                    //부순사람 카운트 업
                    SendKill(collision.gameObject.GetComponent <PhotonView> ().ownerId);
                    //부셔진돌 캔버스 제거
                    //DeleteName1 (fracturedObject,collision);
                    //fracturedObject.transform.Find("Canvas").GetComponent<Canvas>().enabled = false;
                    //Debug.Log (fracturedObject.name);
                    fracturedObject.GetComponent <Collider> ().enabled = false;

                    Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody> ();

                    if (fracturableRigidbody != null)
                    {
                        fracturableRigidbody.isKinematic = true;
                    }
                    for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++)
                    {
                        EnableObjectColliders(fracturedObject.ListFracturedChunks[i].gameObject, true);
                    }

                    // Explode

                    fracturedObject.Explode(collision.contacts[0].point, collision.relativeVelocity.magnitude);
                    //죽은돌 삭제
                    GameObject delStone = GameObject.Find(fracturedObject.name);
                    Destroy(delStone);
                }
                // Enable chunk colliders
            }
        }
    }
Esempio n. 8
0
    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Stone")
        {
            if (mujuk == false)
            {
                mujuk = true;
                if (collision.contacts == null)
                {
                    return;
                }

                if (collision.contacts.Length == 0)
                {
                    return;
                }

                // Was it a big enough hit?

                FracturedObject fracturedObject = gameObject.GetComponent <FracturedObject> ();

                if (fracturedObject != null)
                {
                    float fMass = collision.rigidbody != null ? collision.rigidbody.mass : Mathf.Infinity;
                    if (collision.relativeVelocity.magnitude > fracturedObject.EventDetachMinVelocity && fMass > fracturedObject.EventDetachMinVelocity)
                    {
                        // Disable fracturable object collider
                        if (collision.rigidbody != null)
                        {
                            fracturedObject.EventDetachMinMass -= collision.rigidbody.mass;
                        }
                        if (fracturedObject.EventDetachMinMass < 0)
                        {
                            //Debug.Log (collision.gameObject.GetComponent<PhotonView> ().ownerId.ToString ());
                            //부순사람 카운트 업
                            if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 1)
                            {
                                SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k1.text);
                            }
                            if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 2)
                            {
                                SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k2.text);
                            }
                            if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 3)
                            {
                                SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k3.text);
                            }
                            if (collision.gameObject.GetComponent <PhotonView> ().owner.ID == 4)
                            {
                                SendKill(collision.gameObject.GetComponent <PhotonView> ().owner.ID, k4.text);
                            }
                            //부셔진돌 캔버스 제거
                            fracturedObject.GetComponent <Collider> ().enabled = false;

                            Rigidbody fracturableRigidbody = fracturedObject.GetComponent <Rigidbody> ();

                            if (fracturableRigidbody != null)
                            {
                                fracturableRigidbody.isKinematic = true;
                            }
                            for (int i = 0; i < fracturedObject.ListFracturedChunks.Count; i++)
                            {
                                EnableObjectColliders(fracturedObject.ListFracturedChunks [i].gameObject, true);
                            }

                            // Explode

                            fracturedObject.Explode(collision.contacts [0].point, collision.relativeVelocity.magnitude);
                            //죽은돌 삭제
                            GameObject delStone = GameObject.Find(fracturedObject.name);
                            Destroy(delStone);
                        }
                        // Enable chunk colliders
                    }
                }
            }
            StartCoroutine("divine");
        }
    }