Fixed enemy spam spawning if single player

This commit is contained in:
BOTAlex 2024-05-26 03:07:59 +02:00
parent c2928c82d5
commit 9017315bfe
1 changed files with 6 additions and 3 deletions

View File

@ -86,7 +86,7 @@ public class EnemySpawner : NetworkBehaviour
void SpawnWave(float difficulty) void SpawnWave(float difficulty)
{ {
if (enemyList.List.Any(x=>x.Difficulty < 0.1f)) if (enemyList.List.Any(x => x.Difficulty < 0.1f))
{ {
Debug.LogError("Difficulty on prefab too low!", enemyList); Debug.LogError("Difficulty on prefab too low!", enemyList);
return; return;
@ -135,7 +135,10 @@ public class EnemySpawner : NetworkBehaviour
GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform); GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
enemy.GetComponent<NetworkObject>().Spawn(); enemy.GetComponent<NetworkObject>().Spawn();
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray(); if (players != null)
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();
else
enemy.GetComponent<EnemyPathFinding>().targets = new Transform[] { new GameObject("DummyTarget").transform};
} }
// Centrum is SpawnCenter // Centrum is SpawnCenter