Simple way to access data of different types within a nested array?
If for example, a high Adrenalin, heart thumping, full featured AAA production, action packed, competitive racing game where the primary receptacle for transportation is a magic umbrella where players float around racing to predetermined destination like Mary Poppins, I need a way to store the types of Umbrellas available for use. So if they choose to change from a full size "automatic" umbrella, to a faster lightweight solution like a "pocket" umbrella, I can use the array below as such:
Dictionary<string, Dictionary<string, double>> Umbrellas = new Dictionary<string, Dictionary<string, double>>
{
{ "automatic", new Dictionary<string, double> { { "canopy_scale", 0.80 }, { "rib_count", 24 }, { "pole_height", 16 } } },
{ "pocket", new Dictionary<string, double> { { "canopy_scale", 0.23 }, { "rib_count", 12 }, { "pole_height", 7 } } },
{ "golf", new Dictionary<string, double> { { "canopy_scale", 0.70 }, { "rib_count", 30 }, { "pole_height", 20 } } }
};
var ChangeCanopy = true;
var UmbrellaType = 2;
var ChangeRibs = true;
var UmbrellaRibs = 1;
if(ChangeCanopy){
var UmbrellaType = "";
if( ChangeCanopy == 1 ){
//To scale the objects canopy to "automatic" size:
UmbrellaType = "automatic";
}else if( ChangeCanopy == 2 ){
//To scale the objects canopy to "pocket" size:
umbrellaProperty = "canopy_scale";
}else if( ChangeCanopy == 3 ){
//To scale the objects canopy to "golf" size:
umbrellaProperty = "canopy_scale";
}else{
//Default if | input != (1,2,3)
umbrellaProperty = "automatic";
}
var scale = Umbrellas[UmbrellaType][umbrellaProperty];
Umbrella.transform.localScale = new Vector3[scale, scale, scale];
}else if(ChangeRibs){
var RibType = "";
if( UmbrellaRibs == 1 ){
... ect.
This is not how the array would be used in practice, its an over exageration of its functionality. The primary purpose of doing it this was is to rely only on the data
structure itself without any function overhead, or complex classes ... can this be done? In a more managble way then this horid nested array declaration, can an array be
nested inside an array, like so with different types of data where it can contain strings with float or ints as well?? like this:
Dictionary Umbrellas = new Dictionary<string>;
Umbrellas["automatic"]= { "canopy_scale", 0.80 }, { "rib_count", 24 }, { "pole_height", 16 };
Umbrellas["pocket"]= { "canopy_scale", 0.23 }, { "rib_count", 12 }, { "pole_height", 7 };
Umbrellas["golf"]= { "canopy_scale", 0.70 }, { "rib_count", 30 }, { "pole_height", 20 } };
Umbrellas["color"]= { "string", new Dictionary<string> }, { "hex", new Dictionary<string> } };
Umbrellas["color"]["string"]={ "automatic", "red" }, { "pocket", "green" }, { "golf", "blue" };
Umbrellas["color"]["hex"]={ "automatic", 0xFF0000 }, { "pocket", 0x00FF00 }, { "golf", 0x0000FF };
Is there any way to achieve ^ in this a manner, or even a better simple way to organize data that can potentially achieve better performance??? I have searched and cannot find how to nest arrays, and access the value of differing data types by key-name. This is not premature optimization, there has to be a best way to do this ... that is what I am asking