This commit is contained in:
2026-04-22 00:29:09 +07:00
parent 8de65bb527
commit 1e2b7a0dd2
12 changed files with 2215 additions and 181 deletions

View File

@@ -29,7 +29,11 @@ namespace Hallucinate.GameSetup.Maze
if (grid.CountSquareNeighbours(w.x, w.z, MazeCellType.Corridor) == TargetCorridorNeighbours)
{
grid.SetCell(w.x, w.z, MazeCellType.Corridor);
walls.AddRange(GetNeighbouringWalls(grid, w.x, w.z));
foreach (var nw in GetNeighbouringWalls(grid, w.x, w.z))
{
if (!walls.Contains(nw)) walls.Add(nw);
}
}
iterations++;
}
@@ -43,7 +47,6 @@ namespace Hallucinate.GameSetup.Maze
yield return new WaitForSeconds(interval);
List<MapLocation> walls = GetNeighbouringWalls(grid, x, z);
foreach(var w in walls) grid.SetCell(w.x, w.z, MazeCellType.Processing);
int iterations = 0;
@@ -58,8 +61,7 @@ namespace Hallucinate.GameSetup.Maze
grid.SetCell(w.x, w.z, MazeCellType.Corridor);
if (interval > 0) yield return new WaitForSeconds(interval);
var newWalls = GetNeighbouringWalls(grid, w.x, w.z);
foreach(var nw in newWalls)
foreach (var nw in GetNeighbouringWalls(grid, w.x, w.z))
{
if (grid.GetCell(nw.x, nw.z) == MazeCellType.Wall)
{
@@ -70,8 +72,8 @@ namespace Hallucinate.GameSetup.Maze
}
else
{
if(grid.GetCell(w.x, w.z) == MazeCellType.Processing)
grid.SetCell(w.x, w.z, MazeCellType.Wall);
// If it's no longer a candidate, turn it back to Wall
grid.SetCell(w.x, w.z, MazeCellType.Wall);
}
iterations++;
}
@@ -83,10 +85,19 @@ namespace Hallucinate.GameSetup.Maze
foreach (var dir in MapLocation.Directions)
{
int nx = x + dir.x;
int nz = z + dir.z;
if (grid.IsInBounds(nx, nz) && grid.GetCell(nx, nz) == MazeCellType.Wall)
int nz = z + dir.z;
// Correction
nx = x + dir.x;
nz = z + dir.z;
if (grid.IsInBounds(nx, nz))
{
neighbours.Add(new MapLocation(nx, nz));
MazeCellType type = grid.GetCell(nx, nz);
if (type == MazeCellType.Wall || type == MazeCellType.Processing)
{
neighbours.Add(new MapLocation(nx, nz));
}
}
}
return neighbours;