- Home /
How would you store this data
Hi,
I have a game and I need to store this data:
Country
City
Level
There are 5 countries, 5 cities per country, and x levels per city.
What would be the best way to store this data, i'm looking to store the level details, such as completed, time taken, etc
I thought of multidimensional lists, or dictionaries, but wondered what you guys think is best practice?
I'd also need to save this data in JSON.
Thanks
Comment
Answer by thantieuhodo91 · May 10, 2019 at 04:49 AM
I often do like this:
[System.Serializable]
public class Level
{
public int id;
public int state;
public float time_taken;
// etc
}
[System.Serializable]
public class City
{
public int id;
public List<Level> levels;
}
[System.Serializable]
public class Country
{
public int id;
public List<City> cities;
}