I want to store fixed settings for each game level. I want it to be structured like this:
namespace LevelSettings
{
namespace Bar
{
public static int ExtraActiveBlocks = 3;
"Level1"
{ public static float Speed = 0.6f;
public static string ActiveColor = "red";
public static string InactiveColor = "black";
},
"Level2"
{
public static float Speed = 0.6f;
public static string ActiveColor = "red";
public static string InactiveColor = "black";
},
"Level3"
{
public static float Speed = 0.6f;
public static string ActiveColor = "red";
public static string InactiveColor = "black";
}
This is obviously not valid C# code. However I'm asking how to code it in C#.
So in my C# (Unity) script I want to access the fields like this:
str currentLevel = "Level1"
float currentSpeed = LevelSettings.Bar.{currentLevel}.Speed;
Is this storage and access functionality achievable in C#? If so, how can the above be done?