public void GiveThemParts() { foreach (KeyValuePair <string, Piece> entry in recipes) { Inventory.IItem item = entry.Value.ToInventory(); item.Quantity = 1; Inventory.Instance.Add(item, Inventory.Type.Piece); } }
void CreatePiece(Piece piece, int totalQuantity) { foreach (Piece.Requirement requirement in piece.materialsNeeded) { int quantityNecesary = totalQuantity * requirement.quantity; Inventory.Instance.Remove(requirement.material.id, quantityNecesary, Inventory.Type.Material); } Inventory.IItem item = piece.ToInventory(); item.Quantity *= totalQuantity; Inventory.Instance.Add(item, Inventory.Type.Piece); worker.tired += tirednessRate; if (worker.tired >= 1) { Rest(); } }
bool Buy(IItem item, int quantity) { int totalPrice = item.Price * quantity; int money = Inventory.Instance.Money; //Check if there is enough money if (totalPrice <= money) { Inventory.IItem inventoryItem = item.InventoryItem; inventoryItem.Quantity = quantity; Inventory.Instance.Money -= totalPrice; Inventory.Instance.Add(inventoryItem, item.Type); return(true); } return(false); }