private GameObject GenerateWorldChunk(float positionX, bool buffered) { 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)); BaseChunkShape shape; if (buffered == false) { shape = new FlatShape(); } else { shape = eligibleChunkShapes.RandomElement(); } BaseBiome biome; if (buffered == false || lastBiome == null || lastBiome.IsSpecial) { biome = new GrassBiome(); } else { biome = biomes.Choose(); } chunkGenerator.Generate(chunk, shape, biome, buffered); coinGenerator.Generate(chunk, shape, biome, buffered); powerupGenerator.Generate(chunk, shape, biome, buffered); if (GameManager.Instance.distanceTraveled > 1) { enemyGenerator.Generate(chunk, shape, biome, buffered); } lastChunkPosX = (int)positionX; lastBiome = biome; Debug.Log("lastChunkPosX = " + lastChunkPosX); return(chunk); }
public GameScreen() { player = new Player(); grass = new GrassBiome(); }