Пример #1
0
		public Maze (int width, int height)  {
			map = new Cell[width, height];

			//Generate all the cells, and set them as undetermined.
			for (int i = 0; i < map.GetLength (0); i++)
				for (int j = 0; j < map.GetLength (1); j++)
					map [i, j] = new Cell (i, j, 0);
		}
Пример #2
0
		List<Cell> GetNeighbours(Cell cell) {
			var neighbours = new List<Cell> ();

			//If the left neighbour isn't null
			if (cell.X > 0)
				neighbours.Add (map [cell.X - 1, cell.Y]);

			//If the bottom neighbour isn't null
			if (cell.Y > 0)
				neighbours.Add (map [cell.X, cell.Y - 1]);

			//If the right neighbour isn't null
			if (cell.X < map.GetLength (0) - 1)
				neighbours.Add (map [cell.X + 1, cell.Y]);

			//If the top neighbour isn't null
			if (cell.Y < map.GetLength (1) - 1)
				neighbours.Add (map [cell.X, cell.Y + 1]);

			return neighbours;
		}