Fixed spawner errors
This commit is contained in:
parent
f5bea512ef
commit
3baa6c5d25
|
@ -93,12 +93,17 @@ public class NewBehaviourScript : MonoBehaviour
|
|||
|
||||
void SpawnRandom(float difficulty)
|
||||
{
|
||||
while (difficulty > 0.5f) // Spawn until difficulty is less than 0.5f
|
||||
while (difficulty > 1f) // Spawn until difficulty is less than 0.5f
|
||||
{
|
||||
var validEnemies = enemyList.Where(x => x.Difficulty <= difficulty).ToArray();
|
||||
var enemyToSpawn = validEnemies[UnityEngine.Random.Range(0, validEnemies.Length)];
|
||||
int enemyIndex = UnityEngine.Random.Range(0, validEnemies.Length);
|
||||
var enemyToSpawn = validEnemies[enemyIndex];
|
||||
difficulty -= enemyToSpawn.Difficulty;
|
||||
GameObject enemy = Instantiate(enemyToSpawn.prefabs[UnityEngine.Random.Range(0, enemyToSpawn.prefabs.Length)], GetRandomPointOnCircle(mainCam.transform.position, SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
|
||||
|
||||
int variant = UnityEngine.Random.Range(0, enemyToSpawn.prefabs.Length);
|
||||
GameObject variantToSpawn = enemyToSpawn.prefabs[variant];
|
||||
|
||||
GameObject enemy = Instantiate(variantToSpawn, GetRandomPointOnCircle(mainCam.transform.position, SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
|
||||
|
||||
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue