Esempio n. 1
0
	void OnTriggerEnter2D (Collider2D other)
	{
		if (other.tag == "Bullet" || other.tag == "Player") {
			Vector2 Dir1 = Quaternion.Euler (0, 0, 90) * other.transform.up;
			Vector2 Dir2 = Quaternion.Euler (0, 0, -90) * other.transform.up;
			rockProducer = GameObject.Find ("RockProducer").GetComponent<RockProducer> ();

			if (gameObject.tag.Equals ("BigRock")) {
				GameObject splittedRock1 = Instantiate (middleRock, transform.position, Quaternion.identity) as GameObject;
				GameObject splittedRock2 = Instantiate (middleRock, transform.position, Quaternion.identity) as GameObject;
				splittedRock1.GetComponent<MiddleRock> ().SetDir (Dir1.normalized);
				splittedRock2.GetComponent<MiddleRock> ().SetDir (Dir2.normalized);
				rockProducer.addRockNumber ();
			} else if (gameObject.tag.Equals ("MiddleRock")) {
				GameObject splittedRock1 = Instantiate (smallRock, transform.position, Quaternion.identity) as GameObject;
				GameObject splittedRock2 = Instantiate (smallRock, transform.position, Quaternion.identity) as GameObject;
				splittedRock1.GetComponent<SmallRock> ().SetDir (Dir1.normalized);
				splittedRock2.GetComponent<SmallRock> ().SetDir (Dir2.normalized);
				rockProducer.addRockNumber ();
			} else if (gameObject.tag.Equals ("SmallRock")) {
				GameObject splittedRock1 = Instantiate (tinyRock, transform.position, Quaternion.identity) as GameObject;
				GameObject splittedRock2 = Instantiate (tinyRock, transform.position, Quaternion.identity) as GameObject;
				splittedRock1.GetComponent<TinyRock> ().SetDir (Dir1.normalized);
				splittedRock2.GetComponent<TinyRock> ().SetDir (Dir2.normalized);
				rockProducer.addRockNumber ();
			} else if (gameObject.tag.Equals ("TinyRock")) {
				rockProducer.minusRockNumber ();
			}
			Destroy (gameObject);
		}
	}
Esempio n. 2
0
	void OnTriggerEnter2D (Collider2D other)
	{
		if (other.tag == "Bullet" || other.tag == "Player") {
			GameObject splittedRock1 = Instantiate (splittedRockType, transform.position, Quaternion.identity) as GameObject;
			GameObject splittedRock2 = Instantiate (splittedRockType, transform.position, Quaternion.identity) as GameObject;
			Vector2 Dir1 = Quaternion.Euler (0, 0, 90) * other.transform.up;
			Vector2 Dir2 = Quaternion.Euler (0, 0, -90) * other.transform.up;
			splittedRock1.GetComponent<MiddleRock> ().SetDir (Dir1.normalized);
			splittedRock2.GetComponent<MiddleRock> ().SetDir (Dir2.normalized);
			rockProducer = GameObject.Find ("RockProducer").GetComponent<RockProducer> ();
			rockProducer.addRockNumber ();
			Instantiate (explosionSound, transform.position, Quaternion.identity);
			Destroy (gameObject);
		}
	}