57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[CreateAssetMenu(menuName = "Gather And Defend/Levels/WaveConfig")]
|
|
public class WaveConfig : ScriptableObject
|
|
{
|
|
|
|
[SerializeField]
|
|
private List<EnemyType> _constantSpawn = new List<EnemyType>();
|
|
[SerializeField]
|
|
private List<EnemyType> _groupSpawn = new List<EnemyType>(); //TODO: Turn into List of list later on
|
|
[SerializeField]
|
|
private float _gameDuration = 0;
|
|
private float _enemySpawndOnStart = 0;
|
|
private int _enemySum = 0;
|
|
public List<EnemyType> ConstantSpawn
|
|
{
|
|
get
|
|
{
|
|
return _constantSpawn;
|
|
}
|
|
}
|
|
public float GetInterval()
|
|
{
|
|
float interval = _gameDuration * 60.0f / (_enemySum > 0 ? _enemySum.ToFloat() : SumCount()) ;
|
|
return interval;
|
|
}
|
|
public float GetUpdatedInterval()
|
|
{
|
|
_enemySpawndOnStart++;
|
|
float interval = Mathf.Max(_gameDuration * 60.0f / (_enemySum - _enemySpawndOnStart).ToFloat(), 0);
|
|
return interval;
|
|
}
|
|
public EnemyType GetRandomSpawn()
|
|
{
|
|
if (_constantSpawn.Count == 1)
|
|
{
|
|
return _constantSpawn[0];
|
|
}
|
|
return _constantSpawn[Random.Range(0, _constantSpawn.Count - 1)];
|
|
}
|
|
private float SumCount()
|
|
{
|
|
foreach (EnemyType enemy in _constantSpawn)
|
|
{
|
|
_enemySum += enemy.Count;
|
|
}
|
|
return _enemySum.ToFloat();
|
|
}
|
|
|
|
public List<EnemyType> getGroupList()
|
|
{
|
|
return _groupSpawn;
|
|
}
|
|
|
|
}
|