Files
BABA_YAGA/Assets/Scripts/GameSetup/Maze/Crawler.cs

71 lines
2.0 KiB
C#
Raw Normal View History

2026-03-27 22:42:43 +07:00
using UnityEngine;
namespace Hallucinate.GameSetup.Maze
2026-03-27 22:42:43 +07:00
{
/// <summary>
/// A maze generation algorithm that "crawls" through the grid in a semi-random walk.
/// It creates long, winding corridors by moving vertically or horizontally.
/// </summary>
public class Crawler : Maze
2026-03-27 22:42:43 +07:00
{
/// <summary>
/// Orchestrates the crawling generation.
/// (Currently empty as per original procedural logic).
/// </summary>
public override void Generate()
2026-03-27 22:42:43 +07:00
{
// Implementation can be expanded as needed.
2026-03-27 22:42:43 +07:00
}
/// <summary>
/// Performs a vertical crawl starting from a random X position at the bottom.
/// </summary>
protected void CrawlV()
{
bool done = false;
int x = Random.Range(1, width - 1);
int z = 1;
while (!done)
{
map[x, z] = Corridor;
if (Random.Range(0, 100) < 50)
{
x += Random.Range(-1, 2);
}
else
{
z += Random.Range(0, 2);
}
done |= (x < 1 || x >= width - 1 || z < 1 || z >= depth - 1);
}
}
2026-03-27 22:42:43 +07:00
/// <summary>
/// Performs a horizontal crawl starting from a random Z position at the left.
/// </summary>
protected void CrawlH()
2026-03-27 22:42:43 +07:00
{
bool done = false;
int x = 1;
int z = Random.Range(1, depth - 1);
while (!done)
{
map[x, z] = Corridor;
if (Random.Range(0, 100) < 50)
{
x += Random.Range(0, 2);
}
else
{
z += Random.Range(-1, 2);
}
done |= (x < 1 || x >= width - 1 || z < 1 || z >= depth - 1);
}
2026-03-27 22:42:43 +07:00
}
}
}