public int GetCountOfItem(Globals.product item) { if (witchsCoffer.ContainsKey(item)) { return(witchsCoffer[item]); } return(0); }
//This is not a very optimal way of handling the witchhut inventory... void CreateItemPile(Vector2 location, Globals.product itemtype, int amount) { amount = (amount > 12)?12:amount; for (int i = 0; i < amount; ++i) { //Debug.Log("creating a " + itemtype); GameObject go = Instantiate(Resources.Load("PhysIngredient"), new Vector2(location.x + Random.Range(-.6f, .3f), location.y + Random.Range(-.3f, .3f)), Quaternion.identity) as GameObject; go.GetComponent <PhysicalIngredient>().InitializeIngredient(itemtype); } }
public void TallyIncomingGoods(Globals.product prod, int amt) { if (profit.ContainsKey(prod)) { profit[prod] += amt; } else { profit.Add(prod, amt); } }
public void giveResourceBackToVillageCenter(Globals.product resource, int amount) { //checking if we have enough of said resource to give if (RemoveFromWitchesCoffer(resource, amount)) { linkToVillageCenter.addResourceToStorage(resource, amount); } else { Debug.Log("Warning: trying to remove more resources than are stored in Witch's Coffer, cannot give back to VillageCenter"); } }
public void addToWitchsCoffer(Globals.product resource, int amount) { //will add amount passed into witch's coffer if (!witchsCoffer.ContainsKey(resource)) { //then we need to initialize it first with amount we want to add! witchsCoffer.Add(resource, amount); } else { //else, it exists in storage and we can add resource to resourceStorage, adding amount to add with current amount in storage witchsCoffer[resource] = amount + witchsCoffer[resource]; } }
public bool RemoveFromWitchesCoffer(Globals.product resource, int amount) { //check first if resource has amount in storage if (witchsCoffer.ContainsKey(resource) && witchsCoffer [resource] >= amount) { //then we have enough to take the amount we want of said resource witchsCoffer[resource] -= amount; return(true); } else { //we either dont have enough of resource, or resource isn't contained (meaning we have 0 of said resource)... Debug.LogError("Error: attempting to take resource " + resource + " from Witch's Coffer, when none of said resource is stored"); return(false); } }
public bool subtractResourceFromStorage(Globals.product resource, int amount) { //check first if resource has amount in storage if (resourceStorage.ContainsKey(resource) && resourceStorage [resource] >= amount && amount != 0) { //then we have enough to take the amount we want of said resource resourceStorage[resource] = resourceStorage[resource] - amount; //Debug.Log ("Successfully subtracted " + amount + "x " + resource + " from VillageStorage!"); return(true); } else { //we either dont have enough of resource, or resource isn't contained (meaning we have 0 of said resource)... //Debug.Log("Trying to subtract " + amount + "x "+ resource + " from VillageStorage, but there is not enough"); return(false); } }
public void addResourceToStorage(Globals.product resource, int amount) { //check first if it is in the dictionary //if not, then add with amount = 0 then proceed to avoid error if (!resourceStorage.ContainsKey(resource)) { //then we need to initialize it first with amount we want to add! resourceStorage.Add(resource, amount); //Debug.Log ("Successfully added " + amount + "x " + resource + " from VillageStorage! (From zero)"); } else { //else, it exists in storage and we can add resource to resourceStorage, adding amount to add with current amount in storage resourceStorage[resource] = amount + resourceStorage[resource]; //Debug.Log ("Successfully added " + amount + "x " + resource + " from VillageStorage!"); } }
//could do it one one burst with items added, but then wouldn't have the proper colors tells. public void AddIngredient(Globals.product addedIngredient) { Debug.Log("added ingr: " + addedIngredient.ToString()); if (!itemsAdded.ContainsKey(addedIngredient)) { itemsAdded.Add(addedIngredient, 0); } itemsAdded[addedIngredient]++; foreach (Element e in IngredientToElementDictionary.Instance.ElementsFromIngredient(addedIngredient)) { //Debug.Log("elem e consists of " + e.energyType + ", " + e.power); if (!energyStored.ContainsKey(e.energyType)) { energyStored.Add(e.energyType, e.power); } else { energyStored[e.energyType] += e.power; } } }
public void InitializeIngredient(Globals.product _ingredient) { ingredient = _ingredient; SetIngredientGraphic(); }
public List <Element> ElementsFromIngredient(Globals.product ingredient) { return(ingToElemDict[ingredient]); }
public void giveResourceToVillage(Globals.product resource, int amount) { //Debug.Log ("Giving Resources to Village: from " + biomeType + "."); //Debug.Log ("Adding: " + resource + " x" + amount + "."); center.addResourceToStorage(resource, amount); }