diff --git a/Assets/Scripts/Controller/EnemySpawner/EnemySpawner.cs b/Assets/Scripts/Controller/EnemySpawner/EnemySpawner.cs index 943dfae..9b924ca 100644 --- a/Assets/Scripts/Controller/EnemySpawner/EnemySpawner.cs +++ b/Assets/Scripts/Controller/EnemySpawner/EnemySpawner.cs @@ -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().targets = players.Select(x => x.transform).ToArray(); }