public IEnumerator GenerateCoroutine(GameObject chunk, BaseChunkShape chunkShape, BaseBiome biome, bool buffered) { Debug.Log("generating " + chunkShape.Map.Count); if (biome.backgroundPrefab != null) { worldGenerator.CreateBG(chunk, biome.backgroundPrefab); } // ragged top for (int x = 0; x < worldGenerator.chunkWidth; x++) { for (int y = (int)worldGenerator.chunkHeight - 2; y < worldGenerator.chunkHeight; y++) { if (Random.Range(0, 2) == 0) { var tile = worldGenerator.CreateTile(chunk, new Color(0.2f, 0.2f, 0.2f), x, y); } } } foreach (var feature in chunkShape.Map) { switch (feature.TileType) { case BaseChunkShape.TileTypes.Air: break; case BaseChunkShape.TileTypes.Liquid: for (int x = (int)feature.Rect.xMin; x < (int)feature.Rect.xMax; x++) { for (int y = (int)feature.Rect.yMin; y < (int)feature.Rect.yMax; y++) { worldGenerator.CreateTile(chunk, liquidPrefab, x, y); } } break; case BaseChunkShape.TileTypes.Platform: worldGenerator.CreatePlatform(chunk, feature.Rect); worldGenerator.CreateTiles(chunk, biome.tileColor, feature.Rect); break; case BaseChunkShape.TileTypes.Platform50p: if (Random.Range(0, 2) == 0) { worldGenerator.CreatePlatform(chunk, feature.Rect); worldGenerator.CreateTiles(chunk, biome.tileColor, feature.Rect); } break; default: break; } //if (buffered) // yield return new WaitForEndOfFrame(); } yield return(null); }
public void Generate(GameObject chunk, BaseChunkShape chunkShape, BaseBiome biome, bool buffered) { foreach (var feature in chunkShape.Map) { if (feature.TileType == BaseChunkShape.TileTypes.Powerup) { if (Random.Range(0, 3) == 0) { worldGenerator.CreateTile(chunk, powerupHatPrefab, feature.Rect.xMin, feature.Rect.yMin); } else if (Random.Range(0, 5) == 0) { worldGenerator.CreateTile(chunk, powerupBonusPrefab, feature.Rect.xMin, feature.Rect.yMin); } } } }
public void Generate(GameObject chunk, BaseChunkShape chunkShape, BaseBiome biome, bool buffered) { if (GameManager.Instance.Area == GameManager.Areas.Bonus) { return; } foreach (var feature in chunkShape.Map) { if (feature.TileType == BaseChunkShape.TileTypes.Tier1Enemy) { var r = Random.Range(0, 3); Object prefab = null; if (r == 0) { prefab = enemyTier1Prefab; } if (r == 1) { prefab = enemyVinePrefab; } if (prefab != null) { for (var x = (int)feature.Rect.xMin; x < (int)feature.Rect.xMax; x += 2) { for (var y = (int)feature.Rect.yMin; y < (int)feature.Rect.yMax; y += 2) { worldGenerator.CreateTile(chunk, prefab, x, y); } } } } if (feature.TileType == BaseChunkShape.TileTypes.Spike) { for (var x = (int)feature.Rect.xMin; x < (int)feature.Rect.xMax; x++) { for (var y = (int)feature.Rect.yMin; y < (int)feature.Rect.yMax; y++) { worldGenerator.CreateTile(chunk, spikePrefab, x, y); } } } } }
private GameObject GenerateBonusWorldChunk(float positionX, BaseChunkShape shape) { Debug.Log("new chunk at " + positionX); var eligibleChunkShapes = chunkShapes.Where(x => GameManager.Instance.distanceTraveled >= x.Difficulty - 1).ToList(); var chunk = (GameObject)Instantiate(worldChunkPrefab, new Vector3(positionX, GameManager.Instance.Area == GameManager.Areas.Bonus ? 100 : 0, 0), new Quaternion(0, 0, 0, 0)); if (shape == null) { shape = eligibleChunkShapes.RandomElement(); } BaseBiome biome = new BonusBiome(); chunkGenerator.Generate(chunk, shape, biome, false); coinGenerator.Generate(chunk, shape, biome, false); powerupGenerator.Generate(chunk, shape, biome, false); return(chunk); }
public IEnumerator GenerateCoroutine(GameObject chunk, BaseChunkShape chunkShape, BaseBiome biome, bool buffered) { if (biome.GetType() == typeof(BonusBiome)) { for (int x = 0; x < 50; x++) { for (int y = 1; y < 7; y++) { worldGenerator.CreateTile(chunk, biome.coinPrefab, x, y); if (buffered) { yield return(new WaitForEndOfFrame()); } } } } else { foreach (var feature in chunkShape.Map) { if (feature.TileType == BaseChunkShape.TileTypes.Coin) { for (int x = (int)feature.Rect.xMin; x < (int)feature.Rect.xMax; x++) { for (int y = (int)feature.Rect.yMin; y < (int)feature.Rect.yMax; y++) { worldGenerator.CreateTile(chunk, biome.coinPrefab, x, y); } } if (buffered) { yield return(new WaitForEndOfFrame()); } } } } }
public void Generate(GameObject chunk, BaseChunkShape chunkShape, BaseBiome biome, bool buffered) { worldGenerator.StartChildCoroutine(GenerateCoroutine(chunk, chunkShape, biome, buffered)); }