public IEnumerator Spawn(BaddieGroup bg) { for (int idx = 0; idx < bg.amount; idx++) { bool overlapping = true; Vector3 pos = new Vector3(Random.Range(-width / 2, width / 2), 0, Random.Range(-height / 2, height / 2)); pos += transform.position; while (preventOverlap && overlapping) { pos = new Vector3(Random.Range(-width / 2, width / 2), 0, Random.Range(-height / 2, height / 2)); pos += transform.position; if (!Physics.CheckSphere(pos, 1.0f)) { overlapping = false; } } Transform spawned = (Transform)Instantiate(bg.baddieType, pos, transform.rotation); spawned.GetComponent <Baddie>().Spawner = this; aliveCount++; yield return(new WaitForSeconds(bg.spawnDelay)); } }
public IEnumerator RunSpawner(BaddieGroup bg, float startDelay){ yield return new WaitForSeconds(startDelay); GameObject.Find(bg.spawner).GetComponent<Spawner>().Run(bg); }
public void Run(BaddieGroup bg) { StartCoroutine(Spawn(bg)); }
public IEnumerator RunSpawner(BaddieGroup bg, float startDelay) { yield return(new WaitForSeconds(startDelay)); GameObject.Find(bg.spawner).GetComponent <Spawner>().Run(bg); }