Here’s my level data right now:
I’d like to just have one function that builds a level, and then a directory of files that store the instructions for how to build each level. Maybe down the road I can create these in-game and let people download, upload and share levels
.
What kind of files do I write for my level data, and how do I load from them?
I’d probably have a ScriptableObject that I had a list of all levels in, the levels would be stored as a ‘LevelInfo’ struct and contain all the data that should be associated with each level.
This could also be done with xml/json/other serializable format (easier to update post build).
Anyways, a function would interpret this ‘info’ or ‘serialized format’ and perform this code above.
public struct LevelInfo
{
baseWidth;
playerDefenseZoneWidth;
//etc
}
void LoadLevel(LevelInfo info)
{
baseWidth = info.baseWidth;
playerDefenseZoneWidth = info.playerZoneDefenseZoneWidth;
//etc
}
Okay thanks this is a great step forward. Other people also mentioned storing them as json or xml files.
I’ve never used Struct or ScriptableObject before, I don’t really understand them.
I can’t set the values of each float in my struct without getting an error.
Also I don’t know how to write an xml or json file.