idle-survivors/Assets/Scripts/Wave/SpawnPackSO.cs
Michael 505b292718
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Initial pass on wave spawning.
2023-08-02 17:27:45 -04:00

31 lines
966 B
C#

using System.Collections.Generic;
using DefaultNamespace;
using UnityEngine;
using UnityEngine.Assertions;
namespace Wave
{
[CreateAssetMenu(fileName = "SpawnPack", menuName = "Spawn/Pack", order = 0)]
public class SpawnPackSO : ScriptableObject
{
[SerializeField] private List<Enemy> possibleEnemies;
[SerializeField] [Min(0)] private int minCount;
[SerializeField] [Min(0)] private int maxCount;
public IReadOnlyCollection<Enemy> EnemiesToSpawn()
{
Assert.IsTrue(possibleEnemies.Count > 0);
var count = Random.Range(minCount, maxCount);
var enemiesToSpawn = new List<Enemy>();
for (var i = 0; i < count; i++)
{
var enemyIndex = Random.Range(0, possibleEnemies.Count);
enemiesToSpawn.Add(possibleEnemies[enemyIndex]);
}
return enemiesToSpawn;
}
}
}