public static (LevelComponent, IReadOnlyList <Room>) CreateLevel(DefiningMapFragment fragment, Game game) { var branch = new GameBranch { Game = game, Name = "test branch", Length = 1, Difficulty = 1 }; game.Branches.Add(branch); fragment.EnsureInitialized(game); if (fragment.Height != 0) { fragment.LevelHeight = fragment.Height; } if (fragment.Width != 0) { fragment.LevelWidth = fragment.Width; } var level = LevelGenerator.CreateEmpty(branch, 0, game.Random.Seed, game.Manager); var rooms = LevelGenerator.Generate(level, fragment); return(level, rooms); }
public static (LevelComponent, IReadOnlyList <Room>) BuildLevelWithRooms(string map = "", uint?seed = null) { var game = CreateGame(seed); var fragment = new DefiningMapFragment { Map = map, Layout = new EmptyLayout { Coverage = 0 }, CreatureGenerator = new CreatureGenerator { ExpectedInitialCount = 0 }, ItemGenerator = new ItemGenerator { ExpectedInitialCount = 0 } }; return(CreateLevel(fragment, game)); }
public static List <Room> Generate(LevelComponent levelComponent, DefiningMapFragment fragment) { levelComponent.Height = fragment.LevelHeight; levelComponent.Width = fragment.LevelWidth; levelComponent.Terrain = new byte[levelComponent.Height * levelComponent.Width]; levelComponent.WallNeighbours = new byte[levelComponent.Height * levelComponent.Width]; levelComponent.VisibleNeighbours = new byte[levelComponent.Height * levelComponent.Width]; levelComponent.VisibleTerrain = new byte[levelComponent.Height * levelComponent.Width]; levelComponent.KnownTerrain = new byte[levelComponent.Height * levelComponent.Width]; for (var i = 0; i < levelComponent.KnownTerrain.Length; i++) { levelComponent.KnownTerrain[i] = (byte)MapFeature.Unexplored; } levelComponent.EnsureInitialized(); var rooms = fragment.Layout.Fill(levelComponent, fragment); fragment.CreatureGenerator.Fill(levelComponent, rooms); fragment.ItemGenerator.Fill(levelComponent, rooms); return(rooms); }
private static void Verify(string script, DefiningMapFragment fragment) => Verify(script, fragment, f => f.Name, VerifyNoUnicode);