/* * Remove a specified amount of a specified consumable from the inventory */ public bool RemoveConsumable(Ressources.Consumables type, int amount) { foreach (var entry in inventory) { try { Item.Consumable ic = (Item.Consumable)entry.Key; if (ic.GetName() == type) { if (entry.Value - amount == 0) { inventory.Remove(ic); return(true); } else if (entry.Value - amount < 0) { return(false); } else { inventory[ic] = entry.Value - amount; Debug.Log(inventory[ic]); return(true); } } } catch (System.InvalidCastException e) { } } return(false); }
public Consumable(Ressources.Consumables _name, float _weight, int _value) : base(_weight, _value) { itemType = Type.ItemType.consumable; name = _name; }