public override void Generate(SO_Labyrinth l)
    {
        if (l.FloorPrefab == null || l.WallPrefab == null)
        {
            Debug.LogWarning("Floor Prefab or Wall Prefab was null. Returning.");
            return;
        }

        GenerateLabyrinth(l);
    }
    public void GenerateLabyrinth(SO_Labyrinth l)
    {
        l.Labyrinth = new Labyrinth(l.GraphScale, l.CellSize,
                                    // Various booleans
                                    l.SafeMode,
                                    l.Extras.GenerateOuterWall,
                                    l.Extras.GenerateInnerWall,
                                    l.GenerateFloorAsCells,
                                    l.Extras.GenerateRoof,
                                    l.FloorIsPlane,
                                    l.Extras.ZFightCompensate,
                                    // Prefabs
                                    l.FloorPrefab,
                                    l.WallPrefab,
                                    l.Extras.RoofPrefab,
                                    // Optional Parent
                                    labyrinthParent.Find(p => labyrinthParent.IndexOf(p) == labyrinths.IndexOf(l)));

        Labyrinth_Grapher grapher = new Labyrinth_Grapher();

        l.Labyrinth.Graph = grapher.GraphFloor(l.Labyrinth, l.Seed);
        if (l.Labyrinth.Graph.Nodes.Count < 1)
        {
            Debug.LogError("No vertices were created in the graph. Please check your generation settings. Stopping labyrinth generation.");
            return;
        }
        Labyrinth_Builder builder = new Labyrinth_Builder(l.Labyrinth, l.WallYScale, l.WallZScale);

        l.Labyrinth.LabyrinthObj = builder.BuildLabyrinth();
        Labyrinth_DFS dfs = new Labyrinth_DFS();

        dfs.DepthFirstSearch(l.Labyrinth.Graph);
        if (l.GenerateExits)
        {
            dfs.GenerateExits(l.Labyrinth.OuterWall, l.GraphScale, l.Labyrinth, l.Extras.SingleExit);
        }
        if (l.TileReplacer != null)
        {
            l.TileReplacer.ReplaceTiles(l.Labyrinth, l.WallZScale, l.Seed);
        }

        if (!l.SaveGraph)
        {
            l.Labyrinth.Graph = null;
        }
    }
Esempio n. 3
0
 public abstract void Generate(SO_Labyrinth l);