Example #1
0
    private void ShipDie(DeathMode mode)
    {
        //If we are a player!

        StartCoroutine (DieCorotune(mode));
    }
Example #2
0
    private IEnumerator DieCorotune(DeathMode mode)
    {
        if (subsystems.ContainsKey("PlayerController"))
            DoDeathCamera ();

        alive = false;
        //Destroy (this.gameObject,0.1f);
        //stateManager.RequestState("GameMenu");
        if(mode == DeathMode.explode)
        {
            //MeshTriangles.Fracture (subsystems["Body"]);
            //subsystems["Body"].collider
            //yield return null;
            foreach(string key in Keys)
            {

            //	subsystems[key].transform.parent = null;
                (subsystems[key].GetComponent<MonoBehaviourThink>() ).DisableThink();
                foreach(Renderer com in subsystems[key].GetComponents<Renderer>())
                {
                    if(com.enabled == false)
                    {
                        yield return new WaitForSeconds(.01f);
                        com.enabled = true;
                    }
                }
                //foreach(MonoBehaviourThink com in subsystems[key].GetComponents<MonoBehaviourThink>())
                //{
                    //com.transform.parent = null;
                    //com.gameObject.AddComponent<BoxCollider>();
                    //com.gameObject.AddComponent<Rigidbody>();
                    //com.gameObject.rigidbody.detectCollisions  = true;
                    //com.gameObject.rigidbody.useGravity = false;
                    //com.gameObject.rigidbody.velocity = this.transform.rigidbody.velocity;
                //	yield return new WaitForSeconds(.1f);
                //	com.DisableThink();
                //}
                //Destroy(subsystems[key].gameObject.GetComponent<BoxCollider>());
                //yield return new WaitForSeconds(.1f);

                if(subsystems[key].GetComponent<Rigidbody>() == null && key != "Body")
                {
                    subsystems[key].gameObject.AddComponent<Rigidbody>();
                    subsystems[key].gameObject.GetComponent<Rigidbody>().detectCollisions  = true;
                    subsystems[key].gameObject.GetComponent<Rigidbody>().useGravity = false;
                    subsystems[key].gameObject.GetComponent<Rigidbody>().velocity = this.transform.GetComponent<Rigidbody>().velocity;
                }
                yield return new WaitForSeconds(0.05f);
            }
            //Destroy (this.gameObject);

        }
        else
        {

            foreach(string key in Keys)
            {
                foreach(MonoBehaviourThink com in subsystems[key].GetComponents<MonoBehaviourThink>())
                {
                    //if(com as MonoBehaviourThink != null)
                    //	(com as MonoBehaviourThink).DisableThink();
                    com.DisableThink();
                    yield return new WaitForSeconds(0.0001f);
                }

            }

        }
    }