public void TestSpecificDungeonGeneration() { int seed = 1755192844; var structure = AbstractDungeonStructure.Builder.SetStartElement( NodeElement("DungeonGenerationTest/CorrX").AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5, 10)).AddSubElement( NodeElement("DungeonGenerationTest/EndRoom").Build() ).Build() ).AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5)).AddSubElement( NodeElement("DungeonGenerationTest/EndRoom").Build() ).Build() ).AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5, 10)).AddSubElement( NodeElement("DungeonGenerationTest/EndRoom").Build() ).Build() ).AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(3, 4)).AddSubElement( NodeElement("DungeonGenerationTest/EndRoom").Build() ).Build() ).Build()).Build(); structure.ValidateStructure(); var generator = new PrototypeDungeonGenerator(structure, seed); generator.BuildPrototype(); }
private static void TestOptionalPathGeneration(uint optionalPathNumber) { //GIVEN int seed = 123; var structure = AbstractDungeonStructure.Builder.SetStartElement( NodeElement("DungeonGenerationTest/CorrX").AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5, 10)) .SetMetaData(NodeMetaData.Builder.SetOptionalNode().Build()) .AddSubElement( NodeElement("DungeonGenerationTest/EndRoom") .SetMetaData(NodeMetaData.Builder.SetOptionalEndpoint().Build()) .Build() ).Build() ).AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5)) .SetMetaData(NodeMetaData.Builder.SetOptionalNode().Build()) .AddSubElement( NodeElement("DungeonGenerationTest/EndRoom") .SetMetaData(NodeMetaData.Builder.SetOptionalEndpoint().Build()) .Build() ).Build() ).AddSubElement( ConnectionElement("DungeonGenerationTest/Corridors", new RangeI(5, 10)) .SetMetaData(NodeMetaData.Builder.SetOptionalNode().Build()) .AddSubElement( NodeElement("DungeonGenerationTest/EndRoom") .SetMetaData(NodeMetaData.Builder.SetOptionalEndpoint().Build()) .Build() ).Build() ).Build() ).Build(); structure.ValidateStructure(); //WHEN var generator = new PrototypeDungeonGenerator(structure, seed, new PrototypeDungeonGenerator.GenerationParameters { RequiredOptionalEndpointNumber = optionalPathNumber }); var prototypeDungeon = generator.BuildPrototype(); //THEN var endpointCount = prototypeDungeon.Structure.StartElement.TraverseDepthFirst().Count(n => n.MetaData.OptionalEndpoint); Assert.AreEqual(optionalPathNumber, endpointCount); }
private void BuildDungeon( AbstractDungeonStructure structure, int generationSeed, float branchPercent, float margin, PrototypeDungeonGenerator.GenerationParameters parameters) { if (structure.BranchDataWrapper != null) { structure.BranchDataWrapper.BranchPercentage = branchPercent; } structure.StructureMetaData.MarginUnit = margin; var generator = new PrototypeDungeonGenerator(structure, generationSeed, parameters); var prototypeDungeon = generator.BuildPrototype(); _actualStructure = prototypeDungeon.BuildDungeonInUnitySpace(transform); OnDungeonRebuilt?.Invoke(_actualStructure); }