예제 #1
0
    void Start()
    {
        float weight;

        if (ExplosionSound)
        {
            this.GetComponent <AudioSource>().clip = ExplosionSound;
        }

        foreach (Rigidbody RigidB in GameObject.FindObjectsOfType(typeof(Rigidbody)))
        {
            BoxCollider Box = RigidB.GetComponent <BoxCollider> ();
            RigidB.name = RigidB.GetInstanceID().ToString();
            RigidB.Sleep();

            Box.size = Box.size / 1.5f;
            weight   = Box.size.x + Box.size.y + Box.size.z;
            if (weight == 0)
            {
                Destroy(RigidB);
            }
            else
            {
                RigidB.GetComponent <Rigidbody>().mass = weight * 10.0f;
            }
        }
        InvokeRepeating("checkRigidBodySpeed", 0.5f, 1.0f);
    }
예제 #2
0
 IEnumerator wallLayerSleep()
 {
     foreach (Rigidbody RigidB in GameObject.FindObjectsOfType(typeof(Rigidbody)))
     {
         if (RigidB.gameObject.tag.Contains("WallLayer"))
         {
             RigidB.name = RigidB.GetInstanceID().ToString();
             RigidB.Sleep();
         }
     }
     yield return(null);
 }
예제 #3
0
 void OnEnable()
 {
     foreach (Rigidbody RigidB in this.transform.GetComponentsInChildren(typeof(Rigidbody)))
     {
         BoxCollider Box = RigidB.GetComponent <BoxCollider> ();
         RigidB.name = RigidB.GetInstanceID().ToString();
         RigidB.Sleep();
         Box.size = Box.size / 1.5f;
         float weight = Box.size.x + Box.size.y + Box.size.z;
         if (weight == 0)
         {
             Destroy(RigidB);
         }
         else
         {
             RigidB.GetComponent <Rigidbody>().mass = weight * 50.0f;
         }
     }
 }
예제 #4
0
    void Awake()
    {
        //	CancelInvoke ("rigidBodySleep");
        Time.timeScale = 0;


        this.GetComponent <AudioSource>().volume            = 1;
        defaultHitSound.GetComponent <AudioSource>().volume = 1;

        foreach (Rigidbody RigidB in GameObject.FindObjectsOfType(typeof(Rigidbody)))
        {
            if (RigidB.gameObject.tag.Contains("WallLayer"))
            {
                RigidB.name = RigidB.GetInstanceID().ToString();
                RigidB.Sleep();
                RigidB.gameObject.GetComponent <AudioSource>().volume      = 1;
                RigidB.gameObject.GetComponent <AudioSource>().rolloffMode = AudioRolloffMode.Linear;
            }
        }

        Time.timeScale = 1;
    }