This commit is contained in:
2026-06-26 00:21:29 +07:00
parent 5d1af952b1
commit 4fa3fb2c15
16 changed files with 221 additions and 2011 deletions

View File

@@ -32,17 +32,17 @@ namespace Hallucinate.GameSetup.Maze
}
}
public IEnumerator GenerateStepByStep(MazeGrid grid, float interval)
public IEnumerator GenerateStepByStep(MazeGrid grid, int cellsPerFrame)
{
int x = Random.Range(MinBoundary, grid.Width - 1);
int z = Random.Range(MinBoundary, grid.Depth - 1);
grid.SetCell(x, z, MazeCellType.Corridor);
yield return new WaitForSeconds(interval);
yield return null;
int safety = 0;
while (GetAvailableCells(grid) > 1 && safety < MaxIterationSafety)
{
yield return RandomWalk(grid, interval);
yield return RandomWalk(grid, cellsPerFrame);
safety++;
}
}
@@ -123,7 +123,7 @@ namespace Hallucinate.GameSetup.Maze
}
}
private IEnumerator RandomWalk(MazeGrid grid, float interval)
private IEnumerator RandomWalk(MazeGrid grid, int cellsPerFrame)
{
if (_notUsed.Count == 0) yield break;
@@ -139,7 +139,12 @@ namespace Hallucinate.GameSetup.Maze
while (cx > 0 && cx < grid.Width - 1 && cz > 0 && cz < grid.Depth - 1 && loop < MaxWalkSteps && !validPath)
{
grid.SetCell(cx, cz, MazeCellType.Processing); // State 0
if (interval > 0) yield return new WaitForSeconds(interval);
MazeManager.cellsProcessedThisFrame++;
if (MazeManager.cellsProcessedThisFrame >= cellsPerFrame)
{
MazeManager.cellsProcessedThisFrame = 0;
yield return null;
}
if (CountFinalizedNeighbours(grid, cx, cz) > 1) break;