So I’m creating a Enemy Generator Class, which spawns enemies at specific times. So it has to know how many of that enemy to spawn, which enemy it’d like to spawn and at what time. I’d use this Generator Classes on each of the cardinal directions on the camera. The data structure to be passed into the Class would be something like:
[
[
time => 60
enemies => [{
numberToSpawn: 10,
enemyType: 'Peasant'
},
{
numberToSpawn: 5,
enemyType: 'Town Guard'
}
]
],
[
time => 70
enemies => [{
numberToSpawn: 5,
enemyType: 'Town Guard'
},
{
numberToSpawn: 5,
enemyType: 'Rookie'
}
]
]
]
What’s the best approach to passing the data in like this so I can configure it on the fly?
Update: I think i might be on the right lines, correct me if I’m wrong, I’ve thought about creating a new Enemy Generator Data Class and then pass this into my Enemy Generator Class as a List. So this would be a property on my Enemy Generator Class:
public List<EnemyGeneratorDataLogic> list = new List<EnemyGeneratorDataLogic>();
Second Update:
So now I have 3 Classes:
Enemy Generator,
Enemy Generator Data,
Enemy Data.
So the Classes look like this:
public class EnemyGeneratorLogic : MonoBehaviour
{
public List<EnemyGeneratorDataLogic> enemyGeneratorData = new List<EnemyGeneratorDataLogic>();
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
So that takes a list of EnemyGeneratorData. The EnemyGeneratorData then has these two properties on it:
public class EnemyGeneratorDataLogic : MonoBehaviour
{
public float time;
public List<EnemyDataLogic> enemyData = new List<EnemyDataLogic>();
}
The last Class then sets the data for the enemy data, so the number of enemies and the enemy type:
public class EnemyDataLogic : MonoBehaviour
{
public int numberOfEnemies;
public string nameOfEnemy;
}