Esempio n. 1
0
    public void DropItems()
    {
        GameObject itemPickupPrefab = Manager.inventoryManager.GetItemPickupPrefab();

        for (int i = 0; i < droppableItems.Count; i++)
        {
            GameObject itemToBeDropped = itemPickupPrefab;
            ItemPickup itemPickup      = itemToBeDropped.GetComponent <ItemPickup>();
            itemPickup.SetItem(droppableItems[i]);
            itemPickup.SetStackQuantity(1);
            itemPickup.SetImage();
            itemPickup.SetWasDropped(false);
            var spawnedItem = Instantiate(itemPickup, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z), Quaternion.identity);
        }
    }
Esempio n. 2
0
 public void PlayerDropItem()
 {
     if (draggedSlot != null)
     {
         print("Dropping item");
         GameObject player = GameObject.FindGameObjectWithTag("Player");
         GameObject itemPickupGameObject = itemPickupPrefab;
         ItemPickup newItemPickup        = itemPickupGameObject.GetComponent <ItemPickup>();
         newItemPickup.SetItem(draggedSlot.Item);
         newItemPickup.SetStackQuantity(draggedSlot.Amount);
         newItemPickup.SetImage();
         newItemPickup.SetWasDropped(true);
         var itemPickup = Instantiate(itemPickupGameObject, new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z), Quaternion.identity);
         draggedSlot.Item   = null;
         draggedSlot.Amount = 0;
         ClearDraggedItem();
         Manager.hotbarManager.UpdateHotbarSlots();
     }
 }