public Chunk(long key, Vector2 worldPosition, BiomeType biomeType, BiomeType[] neighbourBiomeTypes, GameObject groundPrefab = null, WorldController parent = null) { this.key = key; _worldPosition = worldPosition; _biomeType = biomeType; this.neighbourBiomeTypes = neighbourBiomeTypes; this.parent = parent; name = worldPosition.ToString(); SetNoSpawnZone(); myBiomeItems = parent._biomeDatabase.GetBiomeItems(_biomeType); CreateChunk(groundPrefab); if (debug) { chunkData.SetChunkData(key, _worldPosition, biomeType, neighbourBiomeTypes, _isVisible); } }
private void SortBiomeItems() { if (gameItems == null || gameItems.Count <= 0) { Debug.LogWarning("Could not sort biome items"); return; } string[] biomeTypes = System.Enum.GetNames(typeof(BiomeType)); for (int i = 0; i < biomeTypes.Length; i++) { BiomeItemsDatabase newBiomeItems = new BiomeItemsDatabase(); foreach (BaseItem item in gameItems) { if (item.biomeTypes == null || item.biomeTypes.Length <= 0) { continue; } for (int j = 0; j < item.biomeTypes.Length; j++) { if (biomeTypes[i] == item.biomeTypes[j].ToString()) { string itemBaseID = item._id.Substring(0, 2); if (itemBaseID == "13") { newBiomeItems.trees.Add(item); //newBiomeItems.biomeObjectTypes[0].Add(item); } else if (itemBaseID == "12") { newBiomeItems.rocks.Add(item); //newBiomeItems.biomeObjectTypes[1].Add(item); } else if (itemBaseID == "11") { newBiomeItems.plants.Add(item); //newBiomeItems.biomeObjectTypes[2].Add(item); } else if (itemBaseID == "10") { newBiomeItems.grasses.Add(item); //newBiomeItems.biomeObjectTypes[3].Add(item); } else if (itemBaseID == "1") { newBiomeItems.animals.Add(item); //newBiomeItems.biomeObjectTypes[4].Add(item); } else if (itemBaseID == "14") { newBiomeItems.foods.Add(item); //newBiomeItems.biomeObjectTypes[5].Add(item); } else if (itemBaseID == "17") { newBiomeItems.resources.Add(item); } } } } biomeItemsDictionary.Add((BiomeType)System.Enum.Parse(typeof(BiomeType), biomeTypes[i]), newBiomeItems); } }