public void createObject(int productID, int productAmount, int[] componentID, int[] componentAmount) { //Dictionary<Item, int> inventory = inventoryModel.inventory; // Does the inventory contains the components ? bool isCreatable = true; for (int k = 0; k < componentID.Length && isCreatable; k++) { // looping on the //ToDo use the controller with GetQuantity() if (countItemId(componentID[k]) < componentAmount[k]) { isCreatable = false; } } if (isCreatable && inventoryController.CanItFit(productID, productAmount)) { // Enough of every components // Adds the product a productAmount of times inventoryController.AddItem(productID, productAmount); GameObject.Find("Data").GetComponentInChildren <OtherStats>().CraftedItems++; // Remove the components for (int k = 0; k < componentID.Length; k++) {// looping on the components inventoryController.RemoveItem(componentID[k], componentAmount[k]); } } else { Debug.Log("Component not creatable"); } }