void PauseToggle() { GameObject[] go_NanobotDevour = GameObject.FindGameObjectsWithTag("Destructible"); //If the P key is pressed down if (Input.GetKeyDown ("p")) { //Toggles between true and false bl_HelpToggle = !bl_HelpToggle; } if(bl_HelpToggle) { //Freezes the game and the particle effects as well as disabling the use of the nanobots Time.timeScale = 0f; foreach(GameObject go in go_NanobotDevour) { NanobotScript = go.GetComponent<TL_NanobotDevour>(); NanobotScript.enabled = false; } } else { //Un-freezes the game and the particle effects as well as enabling the use of the nanobots Time.timeScale = 1f; foreach(GameObject go in go_NanobotDevour) { NanobotScript = go.GetComponent<TL_NanobotDevour>(); NanobotScript.enabled = true; } } }
public void Reset() { //Sets the PC's position to the spawn point go_PC.transform.position = v3_SpawnPoint; //Sets the rotation facing the entrance of the room go_PC.transform.eulerAngles = new Vector3(0, 270f, 0); //Turns off the pickup PickUpScript.bl_PickUp = false; foreach(Transform tr in go_PC.transform) { if(tr.tag == "Weight") { Rigidbody rb_ = tr.gameObject.GetComponent<Rigidbody>(); //Sets the parent to the laser room tr.SetParent(GameObject.Find ("Laser_Room").transform); //Freezes rotation rb_.constraints = RigidbodyConstraints.FreezeRotation; //Turns gravity on rb_.useGravity = true; } } //Sets the initial positions and rotations to the weights in the list for(int c=0; c < lt_Weights.Count; c++) { lt_Weights[c].gameObject.transform.position = new Vector3(lt_WeightPos[c].x, lt_WeightPos[c].y, lt_WeightPos[c].z); lt_Weights[c].gameObject.transform.rotation = new Quaternion(0, 0, 0, 0); } for(int i=0; i < in_Count; i++) { if(lt_Cubes[i] != null) { //Grabs the nanobot scripts from every cube and sets contact with nanobots bool to false NanobotScript = lt_Cubes[i].gameObject.GetComponent<TL_NanobotDevour>(); NanobotScript.bl_ContactWithNanobots = false; //Destroys the nanobots attached to the cubes foreach(Transform tr_Child in lt_Cubes[i].transform) { Destroy (tr_Child.gameObject); } //Sets both the velocity and angular velocity to zero lt_Cubes[i].gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero; lt_Cubes[i].gameObject.GetComponent<Rigidbody>().angularVelocity = Vector3.zero; //Sets the initial positions and rotations lt_Cubes[i].transform.position = new Vector3(lt_Destructibles[i].x, lt_Destructibles[i].y, lt_Destructibles[i].z); lt_Cubes[i].transform.rotation = new Quaternion(0, 0, 0, 0); //Sets the scale to one lt_Cubes[i].transform.localScale = new Vector3(1f, 1f, 1f); } else { //If there are any cubes missing then re-instantiate them lt_Cubes[i] = (GameObject) Instantiate(go_Cubes, new Vector3(lt_Destructibles[i].x, lt_Destructibles[i].y, lt_Destructibles[i].z), new Quaternion(0, 0, 0, 0)); //Sets both the velocity and angular velocity to zero lt_Cubes[i].gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero; lt_Cubes[i].gameObject.GetComponent<Rigidbody>().angularVelocity = Vector3.zero; //Sets the scale to one lt_Cubes[i].transform.localScale = new Vector3(1f, 1f, 1f); } } }