// Update is called once per frame void Update() { timeActive += Time.deltaTime; if (restartScript.exploding) { timeActiveExploded += Time.deltaTime; if (timeActiveExploded > 10) { Destroy(this.gameObject); } } if (transform.position.y > -0.95f && restartScript.exploding == false) { transform.position = new Vector3(transform.position.x, -0.9599f, transform.position.z); } Collider[] colliders = Physics.OverlapBox(transform.position, new Vector3(0.1f, 0.1f, 0.1f)); foreach (Collider col in colliders) { if (col.name == "NuclearCube") { if (!transitioning) { Renderer[] innerCubes = gameObject.GetComponentsInChildren <Renderer>(); StartCoroutine(NuclearCubeTransition(innerCubes)); } } } if (restartScript.loading) { SaveToXMLScript saveScript = GameObject.Find("SaveObject").GetComponent <SaveToXMLScript>(); if (saveScript.readBlankCubeType == "GRASS") { GameObject newCube = Instantiate(grassPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "SNOW") { GameObject newCube = Instantiate(snowPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "SAND") { GameObject newCube = Instantiate(sandPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "DIRT") { GameObject newCube = Instantiate(dirtPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } } }
// Update is called once per frame void Update() { timeActive += Time.deltaTime; if (restartScript.exploding) { timeActiveExploded += Time.deltaTime; if (timeActiveExploded > 10) { Destroy(this.gameObject); } } if (transform.position.y > -0.95f && restartScript.exploding == false) { transform.position = new Vector3(transform.position.x, -0.9599f, transform.position.z); } if (restartScript.loading) { SaveToXMLScript saveScript = GameObject.Find("SaveObject").GetComponent <SaveToXMLScript>(); if (saveScript.readBlankCubeType == "GRASS") { GameObject newCube = Instantiate(grassPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "SNOW") { GameObject newCube = Instantiate(snowPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "SAND") { GameObject newCube = Instantiate(sandPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } if (saveScript.readBlankCubeType == "DIRT") { GameObject newCube = Instantiate(dirtPrefab, transform.position, Quaternion.identity); Destroy(this.gameObject); } } }
// Start is called before the first frame update void Start() { saveScript = GameObject.Find("SaveObject").GetComponent <SaveToXMLScript>(); doneButton.SetActive(false); finishedPopup.SetActive(false); }