public LandscapeSky( LandscapeGenerator landscapeGenerator, ImageLoader imageLoader) { _landscapeGenerator = landscapeGenerator; _sky = imageLoader.Load("sky.png"); }
public LandscapeLand( LandscapeGenerator landscapeGenerator, ImageLoader imageLoader) { _landscapeGenerator = landscapeGenerator; _floor = imageLoader.Load("floor.png"); }
private void Awake() { if (_instance == null) { _instance = this; } }
public void Build() { _dispersion = CellPrefab.Count - 1; var children = _prefabsParent.GetComponentsInChildren <Transform>(); foreach (var child in children) { if (child != _prefabsParent) { DestroyImmediate(child.gameObject); } } var creator = new LandscapeGenerator(_size, _dispersion, _scale, _seed); creator.Build(); for (int x = 0; x < _size.x; x++) { for (int y = 0; y < _size.y; y++) { Debug.Log(creator.HeightMap[x, y]); var position = new Vector3(x, creator.HeightMap[x, y], y); if (CellPrefab[creator.HeightMap[x, y]] != null) { var cell = Instantiate(CellPrefab[creator.HeightMap[x, y]], position, Quaternion.identity); cell.transform.parent = _prefabsParent; } } } }
void Start() { landscape = GetComponent <LandscapeGenerator>(); regions = MapVariables.regions; noiseMap = MapVariables.noiseMap; tileHealthMap = new float[MapVariables.mapSize, MapVariables.mapSize]; SetTileHealthValues(); }
public void Generate(LandscapeGenerator rootGenerator) { m_generator = rootGenerator; m_root = rootGenerator.Root; DoGenerate(); Finish(); }
public void GenerateMap() { data = new MapData(xSize, ySize); mapController.mapData = data; if (landGenerator == null) landGenerator = new LandscapeGenerator(xSize, ySize); GenerateData(); GenerateMesh(); }
public override void OnInspectorGUI() { LandscapeGenerator landscapeGenerator = (LandscapeGenerator)target; if (DrawDefaultInspector()) { landscapeGenerator.GenerateLandscape(); } }
void Start() { int[,] landscape = new LandscapeGenerator().generateLandscape(); for (int i = 0; i < LandscapeGenerator.maxHeight; i++) { for (int j = 0; j < LandscapeGenerator.lenght; j++) { createBlock(landscape [i, j], j, i); } } }
protected override Tile[,] GenerateFeatures(int width, int height, Configuration config) { Tile[,] output = new Tile[width, height]; List <Tile[, ]> featureLayers = new List <Tile[, ]>(); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <DirtFloor>(width, height, 1, 1)); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <Grass>(width, height, config.Surface.GrassScale, config.Surface.GrassCoverage)); return(output); }
public LandscapeTerrain( LandscapeGenerator landscapeGenerator, ImageLoader imageLoader) { _landscapeGenerator = landscapeGenerator; foreach (var(key, value) in _terrain) { var image = imageLoader.Load(value); _terrainImages[key] = image ?? throw new FileNotFoundException(value); } _army = imageLoader.Load("t_army0.png") ?? throw new FileNotFoundException("t_army0.png"); }
public LandscapeBitmapGenerator( IEntityResolver entityResolver, LandscapeLand landscapeLand, LandscapeSky landscapeSky, LandscapeTerrain landscapeTerrain, LandscapeGenerator landscapeGenerator) { _entityResolver = entityResolver; _landscapeLand = landscapeLand; _landscapeSky = landscapeSky; _landscapeTerrain = landscapeTerrain; _landscapeGenerator = landscapeGenerator; }
protected override Tile[,] GenerateFeatures(int width, int height, Configuration config) { Tile[,] output = new Tile[width, height]; List <Tile[, ]> featureLayers = new List <Tile[, ]>(); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <DirtWall>(width, height, 1, 1)); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <DirtFloor>(width, height, config.Underground.TunnelScale, config.Underground.TunnelCoverage)); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <StoneWall>(width, height, config.Underground.StoneScale, config.Underground.StoneCoverage)); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <StoneWall>(width, height, config.Underground.StoneScale, config.Underground.StoneCoverage)); featureLayers.Add(LandscapeGenerator.CreateTileDistribution <OreWall>(width, height, config.Underground.OreScale, config.Underground.OreCoverage)); featureLayers.ForEach((f) => LandscapeGenerator.ApplyDistributionToTileArray(output, f)); return(output); }
public void Generate() { LandscapeGenerator generator = GetComponent <LandscapeGenerator>(); generator.Generate(this); }
public void Run() { LoadQueue = new ChunkQueue(); GenerationQueue = new ChunkQueue(); VegetationQueue = new ChunkQueue(); BuildQueue = new ChunkQueue(); SetupQueue = new ChunkQueue(); UnloadQueue = new ChunkQueue(); Chunk currentChunk; while (true) { if (!Variables.Game.IsInitialized) { continue; } if (UnloadQueue.Count > 0) { currentChunk = UnloadQueue.Dequeue(); if (currentChunk == null) { continue; } // Unload Chunk if (Constants.World.SaveDynamicWorld) { ChunkManager.StoreChunkImmediate(currentChunk); } else { currentChunk = null; } Console.Write("UnloadQueue: " + GenerationQueue.Count); // End Unload Chunk LoadQueue.Remove(currentChunk); GenerationQueue.Remove(currentChunk); SetupQueue.Remove(currentChunk); } else if (LoadQueue.Count > 0) { currentChunk = LoadQueue.Dequeue(); if (currentChunk == null) { continue; } // Load Chunk ChunkManager.LoadChunkImmediate(currentChunk); currentChunk.BuildOctree(); currentChunk.HasData = true; Console.Write("LoadQueue: " + GenerationQueue.Count); // End Load Chunk if (SetupQueue.Contains(currentChunk)) { SetupQueue.Remove(currentChunk); SetupQueue.Enqueue(currentChunk); } else { SetupQueue.Enqueue(currentChunk); } } else if (GenerationQueue.Count > 0) { currentChunk = GenerationQueue.Dequeue(); if (currentChunk == null) { continue; } // Generate Chunk LandscapeGenerator.SetChunkTerrain(currentChunk); Console.Write("GenerationQueue: " + GenerationQueue.Count); // End Generate Chunk if (VegetationQueue.Contains(currentChunk)) { VegetationQueue.Remove(currentChunk); VegetationQueue.Enqueue(currentChunk); } else { AddToVegetation(currentChunk); } } else if (VegetationQueue.Count > 0) { currentChunk = VegetationQueue.Dequeue(); if (currentChunk == null) { continue; } // Vegetate Chunk Vegetation.Vegetate(currentChunk); Console.Write("VegetationQueue: " + VegetationQueue.Count); // End Vegetate Chunk if (BuildQueue.Contains(currentChunk)) { BuildQueue.Remove(currentChunk); BuildQueue.Enqueue(currentChunk); } else { AddToBuild(currentChunk); } if (VegetationQueue.Count == 0 && !Constants.Engine_Physics.Player.IsReleased) { Constants.Engine_Physics.Player.Release(); } } else if (BuildQueue.Count > 0) { currentChunk = BuildQueue.Dequeue(); if (currentChunk == null) { continue; } // Build Chunk currentChunk.BuildOctree(); currentChunk.HasData = true; Console.Write("BuildQueue: " + BuildQueue.Count); // End Build Chunk if (SetupQueue.Contains(currentChunk)) { SetupQueue.Remove(currentChunk); SetupQueue.Enqueue(currentChunk); } else { AddToSetup(currentChunk); } } else if (SetupQueue.Count > 0) { currentChunk = SetupQueue.Dequeue(); if (currentChunk == null) { continue; } currentChunk.SetupState = 4; // Setup Chunk currentChunk.BuildGeometry(false); currentChunk.SetupState = 1; Console.Write("SetupQueue: " + SetupQueue.Count); // End Setup Chunk } } }