void CalculateAccessibilities(APIMaze apiMaze, int width, int height, int row, int column, MazeTile mazeTile) { int currentIndex = GetIndex(column, row, width); string[] currentData = apiMaze.data[currentIndex]; string[] eastData = new string[] { }; string[] southData = new string[] { }; if (column + 1 < width) { eastData = apiMaze.data[currentIndex + 1]; } else if (column + 1 == width) { eastData = new string[] { "west" }; } if (row + 1 < height) { southData = apiMaze.data[currentIndex + width]; } else if (row + 1 == height) { southData = new string[] { "north" }; } CalculateAccesiblePoints(mazeTile, currentData, eastData, southData); }
Maze BuildMaze(APIMaze apiMaze) { int width = apiMaze.size[0]; int height = apiMaze.size[1]; MazeTile[,] tiles = new MazeTile[width, height]; for (int row = 0; row < height; row++) { for (int column = 0; column < width; column++) { MazeTile mazeTile = new MazeTile(column, row); mazeTile.AccessibleTiles = new List <Point>(); tiles[column, row] = mazeTile; CalculateAccessibilities(apiMaze, width, height, row, column, mazeTile); } } int ponyY = apiMaze.pony[0] / width; int ponyX = apiMaze.pony[0] % width; int domokunY = apiMaze.domokun[0] / width; int domokunX = apiMaze.domokun[0] % width; int endpointY = apiMaze.endPont[0] / width; int endpointX = apiMaze.endPont[0] % width; var maze = new Maze { Width = width, Height = height, Difficulty = apiMaze.difficulty, Tiles = tiles, Pony = new Pony(ponyX, ponyY), Domokun = new Monster(domokunX, domokunY), EndPoint = new Point(endpointX, endpointY) }; return(maze); }