I’m a bit puzzled as to the best and most reliable way to store some configuration data for my game. The characteristics of this data are:
- The data is never visible to the player, it is purely back-end to control the creation of certain assets
- The data types are numerous, i.e. bools, floats, strings etc
- The data is constant and does not change
Essentially I have an array of 40 planets that I need to create throughout my game, and each planet has its own unique set of data which I need to access periodically throughout the game, as it plays a role in the creation and appearance of the planets.
There are so many ways to to do this so I am not sure which is best, right now I have just dumped everything into a static class and retrieving it via a dictionary:
public static class PlanetMaterialConfigs
{
// Dictionary to return the correct data config pack by material name
public static Dictionary<string, PlanetMaterialData> allConfigs = new Dictionary<string, PlanetMaterialData>()
{
["Frozen 1C"] = Config_1
// Same for remaining 39 configs
};
// Configuration data for each material
public static PlanetMaterialData Config_1 = new PlanetMaterialData
{
name = "Frozen 1C",
rotationSpeed = Random.Range(6, 12),
terrain = PlanetMaterialData.TerrainType.solid,
waterSpeed = -1,
effect = PlanetMaterialData.EffectType.cloud,
effectTilingXoffset = true,
effectTilingYoffset = false,
pulseEffect = false,
effectStrength = 0.25f,
effectSpeed = 0.33f,
effectPulseTime = -1
};
// .. repeat for 39 more configs
}
I can’t help but feel this is a very poor way of handling this data. Can someone please recommend the best way to go about this? I really want the data itself to be stored, i.e. I do not want to create a bunch of prefab game objects that already have the correct materials applied, that’s a completely different subject and not the point of my question.
Perhaps I should be using some sort of JSON file?