32 lines
1016 B
C#
32 lines
1016 B
C#
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
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 ReadOnlyCollection<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.AsReadOnly();
|
|
}
|
|
}
|
|
} |