Edge FindCheapestLink(MazeNode[,] cells) { Edge cheapestConnection = null; for (int x = 0; x < cells.GetLength(0); x++) { for (int y = 0; y < cells.GetLength(0); y++) { MazeNode cell = cells[x, y]; if (cell.ConnectedNodes == 0) { foreach (Edge conn in cell.Edges) { if (cheapestConnection == null || conn.Weight < cheapestConnection.Weight) cheapestConnection = conn; } } } } return cheapestConnection; }
public virtual void GenerateMaze(MazeNode[,] cells) { for (int x = 0; x < cells.GetLength(0); x++) { for (int y = 0; y < cells.GetLength(1); y++) { MazeNode cell = cells[x, y]; if (cell.Right != null) { cell.Right.Connected = true; cell.Right.MazeCellOne.Left.Connected = true; } if (cell.Above != null) { cell.Above.Connected = true; cell.Above.MazeCellOne.Below.Connected = true; } } } }
private static void GenerateHorizontal(MazeNode[,] cells) { for (int x = 0; x < cells.GetLength(0); x++) { for (int y = 0; y < cells.GetLength(1); y++) { MazeNode cell = cells[x, y]; bool noRoof = false; if (y % 2 == 1) { if (x == cells.GetLength(0) - 1) { noRoof = true; } } else { if (x == 0) { noRoof = true; } } if (noRoof && cell.Above != null) { cell.Above.Connected = true; cell.Above.MazeCellOne.Below.Connected = true; } if (cell.Right != null) { cell.Right.Connected = true; cell.Right.MazeCellOne.Left.Connected = true; } } } }