public void UpdateShopInventory(PartList.Part.Tags targetTag, Ingredient[] inventory, int[] quantities) { switch (targetTag) { case PartList.Part.Tags.plant: plantShopInv.Clear(); plantShopInv.AddRange(inventory); plantQuantities = quantities; break; case PartList.Part.Tags.meat: meatShopInv.Clear(); meatShopInv.AddRange(inventory); meatQuantities = quantities; break; case PartList.Part.Tags.mineral: mineralShopInv.Clear(); mineralShopInv.AddRange(inventory); mineralQuantities = quantities; break; default: break; } }
public int[] GetQuantities(PartList.Part.Tags targetTag) { switch (targetTag) { case PartList.Part.Tags.plant: return(plantQuantities); case PartList.Part.Tags.meat: return(meatQuantities); case PartList.Part.Tags.mineral: return(mineralQuantities); default: break; } return(new int[9]); }
/// <summary> /// Generates an ingredient of a specified tag type /// </summary> public List <Ingredient> GenerateIngredients(int numberOfIngredients, PartList.Part.Tags targetTag, int shopTier) { // Create the list we will return List <Ingredient> Ingredients = new List <Ingredient>(); for (int i = 0; i < numberOfIngredients; i++) { int loopCounter = 0; int MAX_LOOPS = 50; // Create the new ingredient Ingredient ingredient = ScriptableObject.CreateInstance <Ingredient>(); // Keep generating the ingredient ---- do { PartList.Part colourPart = null; PartList.Part descPart = null; PartList.Part typePart = null; // Get a random Colour of the targetted tag, or with the "any" tag at a particular tier or below do { int randIndex = Random.Range(0, Colours.Count); if ((Colours[randIndex].tags.Contains(PartList.Part.Tags.any) || Colours[randIndex].tags.Contains(targetTag)) && Colours[randIndex].tier <= shopTier) { colourPart = Colours[randIndex]; } } while (colourPart == null); // Get a random Descriptor, or with the "any" tag at a particular tier or below do { int randIndex = Random.Range(0, Descriptors.Count); if ((Descriptors[randIndex].tags.Contains(PartList.Part.Tags.any) || Descriptors[randIndex].tags.Contains(targetTag)) && Descriptors[randIndex].tier <= shopTier) { descPart = Descriptors[randIndex]; } } while (descPart == null); // Get a random Type, or with the "any" tag at a particular tier or below do { int randIndex = Random.Range(0, Types.Count); if ((Types[randIndex].tags.Contains(PartList.Part.Tags.any) || Types[randIndex].tags.Contains(targetTag)) && Types[randIndex].tier <= shopTier) { typePart = Types[randIndex]; } } while (typePart == null); // Build that ingredient ingredient = BuildIngredient(colourPart, descPart, typePart); // Keep track of how many times we've tried this, do not infinite loop loopCounter++; } while (Ingredients.Contains(ingredient) && loopCounter < MAX_LOOPS); // --- Until the ingredient is unique, or the we've tried the maximum number of times // Add the ingredient to the list Ingredients.Add(ingredient); } // Only allow the shops to generate an inventory once per day! switch (targetTag) { case PartList.Part.Tags.plant: if (plantShopInv.Count == 0) { plantShopInv = Ingredients; } else { return(plantShopInv); } break; case PartList.Part.Tags.meat: if (meatShopInv.Count == 0) { meatShopInv = Ingredients; } else { return(meatShopInv); } break; case PartList.Part.Tags.mineral: if (mineralShopInv.Count == 0) { mineralShopInv = Ingredients; } else { return(mineralShopInv); } break; default: break; } // Return the list return(Ingredients); }
public int GetTierFromTag(PartList.Part.Tags tag) { return(tier_dict[tag]); }
public void SetTierForTag(PartList.Part.Tags tag, int newTier) { tier_dict[tag] = newTier; }