public static TileMap <TileType> BuildMap(ILayoutGenerator layoutGenerator, IZoneGenerator zoneGenerator, int level, int levelSeed) { Debug.Log(string.Format("Generating level {0}. {1}, {2} ({3})", level, layoutGenerator, zoneGenerator, levelSeed)); Random.InitState(levelSeed); TileMap <TileType> result = new TileMap <TileType>(); try { result.Layout = layoutGenerator.NewLayout(level); while (!layoutGenerator.IsDone(result.Layout, level)) { result.Layout = layoutGenerator.Iterate(result.Layout, level); result = zoneGenerator.PreConnectZones(result, level); result = zoneGenerator.Generate(result, level); result = zoneGenerator.PostConnectZones(result, level); } result.SpawnPoint = zoneGenerator.GetSpawnPoint(result, level); result.ExitPoint = zoneGenerator.GetExitPoint(result, level); } catch (ScriptRuntimeException e) { Debug.Log(e.DecoratedMessage); } return(result); }
public GameSettings(ILayoutGenerator layoutGenerator, IZoneGenerator zoneGenerator, int seed, int numLevels, bool generateStatsLog, ControlMode controlMode) { LayoutGenerator = layoutGenerator; ZoneGenerator = zoneGenerator; Seed = seed; NumLevels = numLevels; GenerateStatsLog = generateStatsLog; ControlMode = controlMode; }
public void Initialize(ILayoutGenerator layoutGenerator, IZoneGenerator zoneGenerator, int seed, int numberOfLevels, ControlMode mode) { currentSeed = seed; this.numberOfLevels = numberOfLevels; mapGenerationManager = Locator.Get <MapGenerationManager>(); mapGenerationManager.SetLayoutGenerator(layoutGenerator); mapGenerationManager.SetZoneGenerator(zoneGenerator); Initialize(mode); }
private void RequestStart() { ILayoutGenerator layoutGenerator = GetLayoutGenerator(); IZoneGenerator zoneGenerator = GetZoneGenerator(); int seed = GetSeed(); int numLevels = GetNumLevels(); bool generateStatsLog = generateStatsToggle.isOn; ControlMode controlMode = GetControlMode(); GameSettings settings = new GameSettings(layoutGenerator, zoneGenerator, seed, numLevels, generateStatsLog, controlMode); Locator.Get <GameFeederManager>().Settings = settings; SceneManager.LoadScene("Game"); }
public void SetLayoutGenerator(ILayoutGenerator layoutGenerator) { Generator.LayoutGenerator = layoutGenerator; }
public PlusAsteroidLayout(ILayoutGenerator layoutGenerator) { AsteroidLayoutName = AsteroidLayoutName.PLUS; LayoutGenerator = layoutGenerator; }
public ScatteredAsteroidLayout(ILayoutGenerator layoutGenerator) { LayoutGenerator = layoutGenerator; }
public NineStripsAsteroidLayout(ILayoutGenerator layoutGenerator) { LayoutGenerator = layoutGenerator; }
public MapGenerator(IZoneGenerator zoneGenerator, ILayoutGenerator layoutGenerator) { ZoneGenerator = zoneGenerator; LayoutGenerator = layoutGenerator; }
protected IMapLayout <TRoom> GenerateLayout(MapDescription <TRoom> mapDescription, ILayoutGenerator <MapDescription <TRoom>, IMapLayout <TRoom> > generator, int timeout = 0, bool showDebugInfo = false) { IMapLayout <TRoom> layout = null; var task = Task.Run(() => layout = generator.GetLayouts(mapDescription, 1)[0]); if (timeout > 0) { var taskCompleted = task.Wait(timeout); if (!taskCompleted) { throw new DungeonGeneratorException("Timeout was reached when generating the layout"); } } if (showDebugInfo) { PrintGeneratorStats((IBenchmarkableLayoutGenerator <MapDescription <TRoom>, IMapLayout <TRoom> >)generator); } return(layout); }