public void OnPointerClick(PointerEventData eventData) { if (persistentInventory.Currency >= item.Value) { shopTooltip.BuyItem(item); for (int i = 0; i < (persistentInventory.itemList.Length / 2); i++) { if (persistentInventory.itemList[i, 0] == 0) { //Checks for sword of deception if (item.ID == 207) { persistentInventory.addItem(208, i); } else { if (item.Stackable) { persistentInventory.addItem(item.ID, -1); } else { persistentInventory.addItem(item.ID, i); } } persistentInventory.Currency -= item.Value; break; } } } else { shopTooltip.TooPoor(item); } }
public void OnEndDrag(PointerEventData eventData) { this.transform.SetParent(inv.slots[slot].transform); this.transform.position = inv.slots[slot].transform.position; for (int x = 0; x < amount; x++) { if (slot < inv.slotCount) { persistentInventory.addItem(item.ID, slot); } else { persistentInventory.addEquipment(item.ID, amount, slot - inv.slotCount); } } GetComponent <CanvasGroup>().blocksRaycasts = true; }
///<summary> /// Loads te inventory including the saved items private void LoadInventory() { PersistentInventoryScript inventory = GameObject.FindObjectOfType <PersistentInventoryScript>(); for (int i = 0; i < inventory.equipmentList.GetLength(0); i++) { for (int inventorySlot = 0; inventorySlot < inventory.equipmentList.GetLength(1); inventorySlot++) { inventory.removeEquipment(inventorySlot, 0); } int slot = PlayerPrefs.GetInt("save_inventory_equipment_" + i + "_slot"); int id = PlayerPrefs.GetInt("save_inventory_equipment_" + i + "_id"); int number = PlayerPrefs.GetInt("save_inventory_equipment_" + i + "_number"); if (slot == 1) { // Ranged weapon number += 4; } if (slot == 0) { // Melee weapon number += 5; } inventory.addEquipment(id, number, slot); } for (int j = 0; j < inventory.itemList.GetLength(0); j++) { int slot = PlayerPrefs.GetInt("save_inventory_items_" + j + "_slot"); int id = PlayerPrefs.GetInt("save_inventory_items_" + j + "_id"); int number = PlayerPrefs.GetInt("save_inventory_items_" + j + "_number"); for (int num = 0; num <= number; num++) { inventory.removeItem(0, j); inventory.addItem(id, slot); } } }