-
-
Save AG-Dan/7ec062b4937d66eb38bb0a8a0168c4e3 to your computer and use it in GitHub Desktop.
A script for programatically modifying the dungeon length. Just assign the correct RuntimeDungeon (also turn off 'Generate on Start') and call this script's Generate() method.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using DunGen; | |
using DunGen.Graph; | |
using UnityEngine; | |
public class ModifyDungeonLength : MonoBehaviour | |
{ | |
public RuntimeDungeon DungeonGenerator; | |
public int MinLength = 5; | |
public int MaxLength = 10; | |
private DungeonFlow originalFlow; | |
private DungeonFlow modifiedFlow; | |
public void Generate() | |
{ | |
// Keep a reference to the original flow asset | |
if (modifiedFlow == null) | |
{ | |
originalFlow = DungeonGenerator.Generator.DungeonFlow; | |
// We make a copy of the dungeon flow before modifying any settings. | |
// If we just modify the original, we'd permanently change the settings | |
// on that asset in our project. | |
// NOTE: This has to be done for any asset we want to modify | |
// (anything derived from ScriptableObject such as tile sets and archetypes) to avoid changing the original | |
modifiedFlow = Instantiate(originalFlow); | |
} | |
// Change the length to whatever we want | |
modifiedFlow.Length.Min = MinLength; | |
modifiedFlow.Length.Max = MaxLength; | |
// Apply the modified flow and generate | |
DungeonGenerator.Generator.DungeonFlow = modifiedFlow; | |
DungeonGenerator.Generate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment