/// <summary> /// Creating cells but not connecting them /// </summary> /// <param name="rows"></param> /// <param name="cols"></param> public CommonMaze(int rows, int cols) { cells = new MazeCell[rows][]; for (int i = 0; i < cells.Length; ++i) { cells[i] = new MazeCell[cols]; } for (int i = 0; i < cells.Length; ++i) { for (int j = 0; j < cells[0].Length; ++j) { cells[i][j] = new MazeCell(i, j); } } for (int i = 0; i < cells[0].Length; ++i) { cells[0][i].Up = NotCell.GetInstance(); cells[cells.Length - 1][i].Down = NotCell.GetInstance(); } for (int i = 0; i < cells.Length; ++i) { cells[i][0].Left = NotCell.GetInstance(); cells[i][cells[0].Length - 1].Right = NotCell.GetInstance(); } }
private Cell GetNextCell(CellPoint point, Direction dir) { switch (dir) { case Direction.Up: point.Row--; if (point.Row < 0) { return(NotCell.GetInstance()); } break; case Direction.Right: point.Column++; if (point.Column >= maze.Columns) { return(NotCell.GetInstance()); } break; case Direction.Down: point.Row++; if (point.Row >= maze.Rows) { return(NotCell.GetInstance()); } break; case Direction.Left: point.Column--; if (point.Column < 0) { return(NotCell.GetInstance()); } break; } return(maze[point]); }