public void buyItem(Item item, int quantity) { if (Vars.cash < (item.cost * quantity)) { Messenger.notEnoughtCash(item.itemName, quantity); return; } if (item.volume > .001f && (playerInventory.getFreeVolume() - (item.volume * quantity)) < 0) { Messenger.showMessage("Недостаточно места в инвентаре."); return; } Vars.cash -= (item.cost * quantity); item.cell.inventory.containerScreen.updateCashTxt(); if (item.quantity == quantity) { playerInventory.addItemToCell(item.cell.takeItem(), null); } else { Item buyed = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>(); buyed.init(DataCopier.copy(item.itemData)); buyed.quantity = quantity; playerInventory.addItemToCell(buyed, null); item.quantity -= quantity; } }
public void applyItemTake(int count) { if (count > 0) { if (takeFromSlot.item.quantity == count) { container.loot.Remove(takeFromSlot.item); inventory.addItemToCell(takeFromSlot.takeItem(), null); } else { takeFromSlot.item.quantity -= count; Item newItem = Instantiate <Transform>(ItemFactory.itemPrefab).GetComponent <Item>().init(DataCopier.copy(takeFromSlot.item.itemData)); newItem.quantity = count; inventory.addItemToCell(newItem, null); } checkAllTaken(); } itemDescriptor.setEnabled(ItemDescriptor.Type.LOOT, null); }