For a game that uses waves of enemies in a specific spawn order, spread among 100 levels, what’s a good way to store that data and read from it?
Right now I’m using a script I wrote that simply randomizes enemy spawning, speeding up with each new wave, but now I’d like to make it more defined per wave however I’m unfamiliar with this type of game design (defining a level’s parameters in text) so I’m not sure where to start…
Should I look into xml files or something of the sort? And how would I structure them? Any help would be appreciated. (If it makes any difference, it’s a mobile game.)
Well depending on what kind of definition you want, you may well be able to just use a very simple structure such as the example below.
public struct LevelParams
{
public string LevelName;
public float TimeBetweenWaves;
public int MaxWaves;
public int EnemiesPerWave;
public float TimeBetweenEnemies;
}
That is of course just a very basic and limited method of defining some simple level parameters, you could hard code these in a file, write a custom editor window for creating them, and if you want to, these simple structures would easily save and load to files. This could be with your own custom text serialization, or the very useful XmlSerialization, or a BinaryFormatter depending on what your comfortable with, and what target platform you are going for.
Hope this helps.