public bool AddItemToInventory(CubeProperties.itemIDs itemID , int number , SlotProperties slot) { if(CubeProperties.cubeProperties.itemDict[itemID].stackable) { SlotProperties temp = CheckIfIsInInvenory( itemID); if( temp != null) { int remainder = temp.UpdateNumberOfItem(number); if(remainder == 0) { slot.UpdateSlot(0,0); return true; } else { slot.UpdateSlot(itemID , remainder); return AddItemToInventory(itemID ,remainder ,slot ); } } } SlotProperties temp1 = GetNextAvailableSlot (itemID); if(temp1 != null) { temp1.UpdateSlot(itemID , number); return true; } return false; }
public void CallCrafting(SlotProperties[] craftingInventorySlots, SlotProperties outputInventorySlots) { //pass in input string inputString = null; int output = 0; int numberOfOutput = 1; for(int i=0; i<craftingInventorySlots.Length; i++) { inputString += ((int)craftingInventorySlots[i].itemID).ToString() + " "; if (craftingInventorySlots.Length == 4) { if (i == 1) inputString += "0 "; if (i == 3) inputString += "0 0 0 0 "; } } if (!masterCrafter) { output = crafting.GetOutput (inputString); numberOfOutput = crafting.GetOutputNumber (inputString); outputInventorySlots.UpdateSlot((CubeProperties.itemIDs)output , numberOfOutput); // outputInventorySlots.itemID = (CubeProperties.itemIDs)output; // outputInventorySlots.numberOfItem = (byte)numberOfOutput; } }
public void AddOneToCrafting(SlotProperties slot) { slot.UpdateSlot (firstSwap.itemID, 1); firstSwap.UpdateNumberOfItem (-1); }
public void SwapWithFirstSlot( SlotProperties slot) { if(firstSwap != null) { if(firstSwap.itemID != slot.itemID || !firstSwap.isStackable || !slot.isStackable) { CubeProperties.itemIDs temp = firstSwap.itemID; int tempNum = firstSwap.numberOfItem; firstSwap.UpdateSlot(slot.itemID , slot.numberOfItem); slot.UpdateSlot(temp , tempNum); } else { int numberSlotsLeft = 64 - slot.numberOfItem; if(firstSwap.numberOfItem < numberSlotsLeft) { slot.UpdateNumberOfItem(firstSwap.numberOfItem); firstSwap.UpdateSlot(0,0); } else { slot.UpdateNumberOfItem(numberSlotsLeft); firstSwap.UpdateNumberOfItem(-numberSlotsLeft); } } } }