I have the following classes:
public class Layer
{
public Tile[,] Grid; //50x50 positions filled with my own Tile struct
}
public class Level
{
public Layer[] Layers; //An array of layers in the level
public List<object> Objects; //And a couple of lists of say, characters or such in the level.
}
public class Area
{
private Level[,] _activeLevels; //3x3 array of the current level and surrounding ones.
}
What I want is to be able to call for instance..
Area.Layers[0].Grid[112, 64];
To get the Tile in Grid[12, 14] from Level[2,1].
More explanation:
Assuming a layer has 50 x 50 positions, I hope the following will explain what I want.
“if I call” => “then I actually want”
Area.Layers[0].Grid[0,0] => Area.Level[0,0].Layers[0].Grid[0,0]
Area.Layers[0].Grid[0,10] => Area.Level[0,0].Layers[0].Grid[0,10]
Area.Layers[0].Grid[0,49] => Area.Level[0,0].Layers[0].Grid[0,49]
Area.Layers[0].Grid[0,50] => Area.Level[0,1].Layers[0].Grid[0,0]
Area.Layers[0].Grid[0,60] => Area.Level[0,1].Layers[0].Grid[0,10]
Area.Layers[0].Grid[0,112] => Area.Level[0,2].Layers[0].Grid[0,12]
–[next part already answered, see below]–
Also, I want to be able to call for instance..
foreach (object o in Area.Objects)
//dostuff
To call a foreach on -all- the objects from the nine levels.
Could anyone give me a nudge in the right direction, some advice on how to achieve this, or heck, plainly code it out?
For
Area.Layers[0].Grid[112, 64]you’d probably be better off with a method of the formArea.GetTile(0, 112, 64)implemented as