void RestockAllSpawnPoints() // Immediately spawn to all spawn points that are free { for (int i = 0; i < spawnPoints.Count; i++) //foreach (QS_SpawnPoint spawn in spawnPoints) { QS_SpawnPoint sp = spawnPoints[i]; if (!sp.occupied) { sp.SpawnItem(SelectRandomItem()); } } // No longer first wave, used if Start Spawned and Random Spawn Point are both ticked firstWave = false; }
void RestockSpawnPoint() // Immediately spawn to one free spawn point, used for random selection of spawn points { // Check if any points are free before continuing availablePoints = 0; for (int i = 0; i < spawnPoints.Count; i++) { QS_SpawnPoint node = spawnPoints[i].GetComponent <QS_SpawnPoint>(); if (!node.occupied) { availablePoints++; } if (availablePoints == 0) { return; } } foreach (Object item in objectsToSpawn) { if (item == null) { Debug.LogError(this.name + " | Quick Spawner has no object to spawn or a null object slot."); return; } } int r = Random.Range(0, spawnPoints.Count); QS_SpawnPoint chosenSpawn = spawnPoints[r]; if (!chosenSpawn.occupied) { chosenSpawn.SpawnItem(SelectRandomItem()); } else { RestockSpawnPoint(); } }
public void RefreshSpawnPoints() // Called From QSEditor_QuickSpawner { // Clear null spawns first for (int i = 0; i < spawnPoints.Count; i++) { QS_SpawnPoint sp = spawnPoints[i]; if (sp == null || sp.spawnerID != spawnerID) { spawnPoints.Remove(spawnPoints[i]); } } // Reassign SpawnerID SetSpawnerID(); // Search scene and add spawn points foreach (QS_SpawnPoint sp in QS_SpawnPoint.FindObjectsOfType(typeof(QS_SpawnPoint))) { if (sp.spawnerID == spawnerID && !spawnPoints.Contains(sp)) { spawnPoints.Add(sp); } } }