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;
        }
    }
Пример #2
0
    public void GenerateLabyrinth()
    {
        Labyrinth = new Labyrinth(graphScale, cellSize,
                                  // Various booleans
                                  safeMode,
                                  extras.GenerateOuterWall,
                                  extras.GenerateInnerWall,
                                  generateFloorAsTiles,
                                  extras.GenerateRoof,
                                  floorIsPlane,
                                  extras.ZFightCompensate,
                                  // Prefabs
                                  floorPrefab,
                                  wallPrefab,
                                  extras.RoofPrefab,
                                  // Optional Parent
                                  extras.LabyrinthParent);

        Labyrinth_Grapher grapher = new Labyrinth_Grapher();

        Labyrinth.Graph = grapher.GraphFloor(Labyrinth, seed);
        if (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(Labyrinth, wallYScale, wallZScale);

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

        dfs.DepthFirstSearch(Labyrinth.Graph);
        if (generateExits)
        {
            dfs.GenerateExits(Labyrinth.OuterWall, graphScale, Labyrinth, extras.SingleExit);
        }
        if (tileReplacer != null)
        {
            tileReplacer.ReplaceTiles(Labyrinth, wallZScale, seed);
        }
    }