Since we cannot serialize multi-dimensional arrays we are limited to using one dimensional arrays along with math to convert from x,y pairs to an index and back out. Here are the current conversion algorithms:
int Width = 3; // Number of cells along the x axis
int Height = 3; // Number of cells along the y axis
GameObject[] Cells = new GameObject[ Width * Height ];
public int CalculateIndex( int x, int y )
{
return y * Width + x;
}
public void CalculateXY(int i, out x, out y)
{
x = i % Width;
y = i / Width;
}
Now, I have the problem where I need to create a 3 dimensional grid which introduces Depth as well as the z axis but I can’t figure out how to inject the changes into the methods above… I’m having a mental block. Please help me on my endeavor.
-jv