I am making a game. The movement of the player is a series of pre-defined stages. Because this principle is the backbone of my game and there are many NPCs at once, I try to make this as efficient as possible. So I want to include the values of each stage by using constants.
At certain events (like a pressed button for the player) the stage switches to another stage. Because I can't refer to another nested class in a constant, I additionally want to set up an array that contains references to each stage.
The names of the classes are written in enums, and I refer by their integer value.
How do I do that? I want to include the solution at the given position in the code.
If there is a better way to do that by the way, I appreciate if you forward me to it.
enum TYPE
{
hum //and more
}
enum HUM
{
standF, stand_jumpF, stand_kneeF, stand_wanderF //and more
}
static class CONST
{
public static class hum
{
public static class standF
{
public const int duration = 1;
public const int actionLeft = (int)HUM.stand_jumpF;
public const int actionRight = (int)HUM.stand_kneeF;
public const int actionFaster = (int)HUM.stand_wanderF;
}
//and more
}
//and more
}
public static class REF
{
public static Type[][] CONST { get; }
static REF()
{
Type[][] REF = new Type[Enum.GetNames(typeof(TYPE)).Length][];
Type[TYPE.hum][] REF = new Type[Enum.GetNames(typeof(HUM)).Length];
for (int i = 0; i < Enum.GetNames(typeof(HUM)).Length; i++)
{
Type[TYPE.hum][i] = //what to do here?
}
}
}
After reading comparable questions about non-nested class I would have used this solution:
Type[TYPE.hum][i] = Type.GetType(Enum.GetName(typeof(HUM), i));
But it doesn't seem to do the trick.