update
This commit is contained in:
@@ -16,13 +16,13 @@ namespace Hallucinate.GameSetup.Maze
|
||||
for (int i = 0; i < HorizontalCrawlerCount; i++) CrawlH(grid, 0);
|
||||
}
|
||||
|
||||
public IEnumerator GenerateStepByStep(MazeGrid grid, float interval)
|
||||
public IEnumerator GenerateStepByStep(MazeGrid grid, int cellsPerFrame)
|
||||
{
|
||||
for (int i = 0; i < VerticalCrawlerCount; i++) yield return CrawlV(grid, interval);
|
||||
for (int i = 0; i < HorizontalCrawlerCount; i++) yield return CrawlH(grid, interval);
|
||||
for (int i = 0; i < VerticalCrawlerCount; i++) yield return CrawlV(grid, cellsPerFrame);
|
||||
for (int i = 0; i < HorizontalCrawlerCount; i++) yield return CrawlH(grid, cellsPerFrame);
|
||||
}
|
||||
|
||||
private IEnumerator CrawlV(MazeGrid grid, float interval)
|
||||
private IEnumerator CrawlV(MazeGrid grid, int cellsPerFrame)
|
||||
{
|
||||
bool done = false;
|
||||
int x = Random.Range(MinBoundary, grid.Width - MinBoundary);
|
||||
@@ -31,7 +31,12 @@ namespace Hallucinate.GameSetup.Maze
|
||||
while (!done)
|
||||
{
|
||||
grid.SetCell(x, z, MazeCellType.Processing);
|
||||
if (interval > 0) yield return new WaitForSeconds(interval);
|
||||
MazeManager.cellsProcessedThisFrame++;
|
||||
if (MazeManager.cellsProcessedThisFrame >= cellsPerFrame)
|
||||
{
|
||||
MazeManager.cellsProcessedThisFrame = 0;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
grid.SetCell(x, z, MazeCellType.Corridor);
|
||||
|
||||
@@ -48,7 +53,7 @@ namespace Hallucinate.GameSetup.Maze
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator CrawlH(MazeGrid grid, float interval)
|
||||
private IEnumerator CrawlH(MazeGrid grid, int cellsPerFrame)
|
||||
{
|
||||
bool done = false;
|
||||
int x = MinBoundary;
|
||||
@@ -57,7 +62,12 @@ namespace Hallucinate.GameSetup.Maze
|
||||
while (!done)
|
||||
{
|
||||
grid.SetCell(x, z, MazeCellType.Processing);
|
||||
if (interval > 0) yield return new WaitForSeconds(interval);
|
||||
MazeManager.cellsProcessedThisFrame++;
|
||||
if (MazeManager.cellsProcessedThisFrame >= cellsPerFrame)
|
||||
{
|
||||
MazeManager.cellsProcessedThisFrame = 0;
|
||||
yield return null;
|
||||
}
|
||||
|
||||
grid.SetCell(x, z, MazeCellType.Corridor);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user