Trick is now pickup-able and is not scored by baskets
This commit is contained in:
@@ -9,9 +9,18 @@ public class Spawner : MonoBehaviour
|
||||
// Time interval between spawns
|
||||
public float spawnInterval = 1f;
|
||||
[SerializeField] private int maxAlive = 0;
|
||||
[SerializeField] private bool spawnOnStart = true;
|
||||
|
||||
private readonly List<GameObject> spawned = new List<GameObject>();
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (spawnOnStart)
|
||||
{
|
||||
SpawnOnce();
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
// Start the spawning process using a Coroutine
|
||||
@@ -35,12 +44,26 @@ public class Spawner : MonoBehaviour
|
||||
continue;
|
||||
}
|
||||
|
||||
// Spawn the object at the spawner's position and rotation
|
||||
var instance = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
|
||||
spawned.Add(instance);
|
||||
SpawnOnce();
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnOnce()
|
||||
{
|
||||
if (objectToSpawn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (maxAlive > 0 && CountAlive() >= maxAlive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var instance = Instantiate(objectToSpawn, transform.position, Quaternion.identity);
|
||||
spawned.Add(instance);
|
||||
}
|
||||
|
||||
private int CountAlive()
|
||||
{
|
||||
for (var i = spawned.Count - 1; i >= 0; i--)
|
||||
|
||||
Reference in New Issue
Block a user