private void ConnectNodes()
{
if(!objectManager.MapData.IsIsoGrid)
{
for (int y=0; y<size_y; y++) {
for (int x=0; x<size_x; x++) {
//Debug.Log(x+", "+ y);
if (x - 1 >= 0) {
nodes [x, y].BorderTiles [(int)Border.DownRight] = nodes [x - 1, y];
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.Down] = nodes [x - 1, y - 1];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.Right] = nodes [x - 1, y + 1];
}
if (x + 1 < size_x) {
nodes [x, y].BorderTiles [(int)Border.UpLeft] = nodes [x + 1, y];
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.Left] = nodes [x + 1, y - 1];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.Up] = nodes [x + 1, y + 1];
}
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.DownLeft] = nodes [x, y - 1];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.UpRight] = nodes [x, y + 1];
}
}
}
else
{
for (int y=0; y<size_y; y++) {
for (int x=0; x<size_x; x++) {
//Debug.Log(x+", "+ y);
if(x%2 == 0){
if (x - 1 >= 0) {
nodes [x, y].BorderTiles [(int)Border.Left] = nodes [x - 1, y];
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.Down] = nodes [x - 1, y - 1];
}
if (x + 1 < size_x) {
nodes [x, y].BorderTiles [(int)Border.Up] = nodes [x + 1, y];
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.Right] = nodes [x + 1, y - 1];
}
}
if(x%2 == 1){
if (x - 1 >= 0) {
nodes [x, y].BorderTiles [(int)Border.Down] = nodes [x - 1, y];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.Left] = nodes [x - 1, y + 1];
}
if (x + 1 < size_x) {
nodes [x, y].BorderTiles [(int)Border.Right] = nodes [x + 1, y];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.Up] = nodes [x + 1, y + 1];
}
}
if (x - 2 >= 0)
nodes [x, y].BorderTiles [(int)Border.DownLeft] = nodes [x - 2, y];
if (x + 2 < size_x)
nodes [x, y].BorderTiles [(int)Border.UpRight] = nodes [x + 2, y];
if (y - 1 >= 0)
nodes [x, y].BorderTiles [(int)Border.DownRight] = nodes [x, y - 1];
if (y + 1 < size_y)
nodes [x, y].BorderTiles [(int)Border.UpLeft] = nodes [x, y + 1];
}
}
}
}