GameObject Allocate(ProcObject o) { if (o.spawnObject.GetComponent <StrafeEnemy>() != null || o.spawnObject.GetComponent <DumbEnemy>() != null) { numEnemiesInGame++; } return(Instantiate(o.spawnObject)); }
void PopulateProcObjects() { for (int i = 0; i < instantiatedObjects.Length; i++) { if (instantiatedObjects[i] == null || IsOutOfRange(instantiatedObjects[i])) { ProcObject obj = weightedList.GetRandomWeightedEntry(); while ((numEnemiesInGame > maxNumEnemiesinGame || waitToSpawnEnemies > 0f) && obj.name.Equals("Enemy")) { obj = weightedList.GetRandomWeightedEntry(); } instantiatedObjects[i] = Allocate(obj); instantiatedObjects[i].transform.position = randomPoint(player.transform.position + Vector3.Scale(player.transform.forward * 10f, new Vector3(1f, 0f, 1f))); } } }