public void BuildMaze() { Cell current = Grid[0, 0]; Stack <Cell> cellStack = new Stack <Cell>(); Random random = new Random(); do { current.Visited = true; var next = current.PickUnvisitedNeighbour(random); if (next == null) { next = cellStack.Pop(); } else { current.AddPath(next); CellVisited?.Invoke(this, new Tuple <Cell, Cell>(current, next)); cellStack.Push(current); } current = next; }while (cellStack.Any()); }
protected virtual void VisitCell(Cell cell) { CellVisited?.Invoke(structure, cell); if (_trackGenerationPath) { GenerationPath.Add(cell); } }