Пример #1
0
 /// <summary>
 /// Updates the position of the item being dropped into this inventory slot.
 /// </summary>
 /// <param name="eventData"></param>
 public void OnDrop(PointerEventData eventData)
 {
     if (DragHandler.itemBeingDragged != null)
     {
         SlotID startID = DragHandler.itemBeingDragged.GetComponent <DragHandler>().start_id;
         Debug.Log("Dropped in slottype:  " + slot.slotID.type);
         if (slot.slotID.type == SlotType.DESTROY)
         {
             selectedItem.reference = null;
             invContainer.DestroyItem(startID);
         }
         else if (slot.slotID.type == SlotType.SHOP)
         {
             selectedItem.reference = null;
         }
         else if (slot.slotID.type == SlotType.SELL)
         {
             invContainer.SellItem(startID);
         }
         else if (startID.type == SlotType.SHOP)
         {
             invContainer.BuyItem(startID, slot.slotID);
         }
         else
         {
             if (invContainer.Swap(startID, slot.slotID))
             {
                 itemDroppedEvent.Invoke();
             }
         }
     }
 }