コード例 #1
0
ファイル: RockSplit.cs プロジェクト: jackielxu/asteroids
	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);
		}
	}
コード例 #2
0
ファイル: TinyRock.cs プロジェクト: jackielxu/asteroids
	void OnTriggerEnter2D (Collider2D other)
	{
		if (other.tag == "Bullet" || other.tag == "Player") {
			rockProducer = GameObject.Find ("RockProducer").GetComponent<RockProducer> ();
			rockProducer.minusRockNumber ();
			Instantiate (explosionSound, transform.position, Quaternion.identity);
			Destroy (gameObject);
		}
	}
コード例 #3
0
ファイル: BigRock.cs プロジェクト: jackielxu/asteroids
	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);
		}
	}
コード例 #4
0
ファイル: Shooting.cs プロジェクト: jackielxu/asteroids
	void Start ()
	{
		shootSource = GetComponent<AudioSource> ();
		gameManager = GameObject.Find ("GameManager").GetComponent<GameManager> ();
		rockProducer = GameObject.Find ("RockProducer").GetComponent<RockProducer> ();
	}