I am having difficulty figuring out how to setup my array correctly.
I have a basic array of tiles set to my array grid[,] this works fine.
Now i am trying to make an array for my edges between grids so i can place down walls.
So i have this: walls[,][,] where each [,] is a grid position, thus each wall separates 2 grid positions.
The end goal here is that i want a wall array with two grid points say A and B such that i can then do:
Wall wallObject = walls[A.x,A.y][B.x,B.y];
Hope that makes sense. I tried doing something like this:
' Now since each 1 tile can have 4 walls i tried to set up my wall array like this but could not work out the syntax correctly to do it:
grids = new Tile[x,y];
walls = new Wall[grids.GetLength(0), grids.GetLength(1)][walls.GetLength(0) * 4, walls.GetLength(1) * 4]; // invalid rank specifier ERROR
for(int i = 0; i < x; i++) {
for(int j = 0; j < y; j++) {
grids[i, j] = new Tile(new Vector3(i, 0, j));
foreach (Vector3 gridNeighbour in AdjacentTiles(new Vector3(i, 0, j))) //4 directions
{
if (!InGrid(gridNeighbour)) continue;
walls[i, j][(int)gridNeighbour.x, (int)gridNeighbour.z] = new Wall(grid[i,j],grid[(int)gridNeighbour.x,(int)gridNeighbour.z]);
}
}}
I get an error on the second line not sure the of the correct way to write it.
I am also fairly sure my logic is wrong since this data setup i think would give me double data for my walls such that i would get wall[gridA][gridB] and wall[gridB][gridA] which i would like to avoid but i don't know how to.
AandBso if i want to find a wall that seperates two specific tiles the idea was to grab it from the array likewalls[A.x,A.y][B.x,B.y]Hope that makes sense. I presumed i would need this kind of array structure to do it.