This commit is contained in:
2018-04-12 17:14:52 +10:00
parent 2c823744f9
commit b2743d59b5
32 changed files with 1202 additions and 10 deletions
+32
View File
@@ -4,6 +4,9 @@ using UnityEngine;
public class MonsterSpawner : MonoBehaviour {
public GameObject monsterPrefab;
public GameObject monsterPrefab2;
public GameObject monsterPrefab3;
public GameObject monsterPrefab4;
public Vector2 motion;
public float delay;
@@ -12,6 +15,16 @@ public class MonsterSpawner : MonoBehaviour {
void Awake() {
audioSource = GetComponent<AudioSource> ();
if (monsterPrefab2 == null) {
monsterPrefab2 = monsterPrefab;
}
if (monsterPrefab3 == null) {
monsterPrefab3 = monsterPrefab;
}
if (monsterPrefab4 == null) {
monsterPrefab4 = monsterPrefab;
}
StartCoroutine (SpawnMonster ());
}
@@ -22,6 +35,25 @@ public class MonsterSpawner : MonoBehaviour {
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
//ugly duplication
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab2);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab3);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
yield return new WaitForSeconds (delay);
monster = Instantiate (monsterPrefab4);
monster.transform.position = transform.position;
monster.GetComponent<Rigidbody2D> ().velocity = motion;
audioSource.Play ();
}
}
}