Esempio n. 1
0
 public void RemoveItem(string name)
 {
     //remove item from inventory, making that spot empty
     for (int i = 0; i < inventoryList1.Count; i++)
     {
         if (inventoryList1[i].name == name)
         {
             InventoryItem temp;
             temp.item         = inventoryList1[i].item;
             temp.empty        = true;
             temp.name         = "Empty";
             inventoryList1[i] = temp;
             InventoryItemManager itemManager = temp.item.GetComponent <InventoryItemManager>();
             itemManager.SetText("Empty");
             //TODO: change image displayed
             return;
         }
     }
     for (int i = 0; i < inventoryList2.Count; i++)
     {
         if (inventoryList2[i].name == name)
         {
             InventoryItem temp;
             temp.item         = inventoryList2[i].item;
             temp.empty        = true;
             temp.name         = "Empty";
             inventoryList2[i] = temp;
             InventoryItemManager itemManager = temp.item.GetComponent <InventoryItemManager>();
             itemManager.SetText("Empty");
             //TODO: change image displayed
             return;
         }
     }
     Debug.Log("Item not found");
 }
Esempio n. 2
0
 public void AddItem(string name)
 {
     //add item to inventory in empty spot
     for (int i = 0; i < inventoryList1.Count; i++)
     {
         if (inventoryList1[i].empty)
         {
             InventoryItem temp;
             temp.item         = inventoryList1[i].item;
             temp.empty        = false;
             temp.name         = name;
             inventoryList1[i] = temp;
             InventoryItemManager itemManager = temp.item.GetComponent <InventoryItemManager>();
             itemManager.SetText(name);
             //TODO: change image displayed
             return;
         }
     }
     for (int i = 0; i < inventoryList2.Count; i++)
     {
         if (inventoryList2[i].empty)
         {
             InventoryItem temp;
             temp.item         = inventoryList2[i].item;
             temp.empty        = false;
             temp.name         = name;
             inventoryList2[i] = temp;
             InventoryItemManager itemManager = temp.item.GetComponent <InventoryItemManager>();
             itemManager.SetText(name);
             //TODO: change image displayed
             return;
         }
     }
     Debug.Log("Inventory full");
 }