예제 #1
0
 private void OnDrop(GameObject m_drag)
 {
     if (UICamera.currentTouchID == -1)
     {
         if (DragDropManager.Instance.DraggedItem is ItemDragObject)
         {
             ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
             if (itemDragObject.ItemSlot != null)
             {
                 BaseItem item     = itemDragObject.Item;
                 Int32    autoSlot = m_itemContainer.Inventory.GetAutoSlot(item);
                 if (autoSlot >= 0)
                 {
                     ItemSlot p_targetSlot = m_itemContainer.ItemSlots[autoSlot];
                     m_itemContainer.DropItem(p_targetSlot);
                 }
             }
         }
         else if (DragDropManager.Instance.DraggedItem is ShopDragObject)
         {
             ShopDragObject shopDragObject = (ShopDragObject)DragDropManager.Instance.DraggedItem;
             shopDragObject.ItemSlot.Parent.DropCallback(m_itemContainer.Inventory, -1);
             DragDropManager.Instance.EndDragAction();
         }
         else if (DragDropManager.Instance.DraggedItem is LootDragObject)
         {
             LootDragObject lootDragObject = (LootDragObject)DragDropManager.Instance.DraggedItem;
             lootDragObject.ItemSlot.Parent.DropCallback(m_itemContainer.Inventory, -1);
             DragDropManager.Instance.EndDragAction();
         }
         else
         {
             DragDropManager.Instance.CancelDragAction();
         }
     }
 }
예제 #2
0
 public virtual void DropItem(ItemSlot p_targetSlot)
 {
     if (DragDropManager.Instance.DraggedItem is ItemDragObject)
     {
         ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
         if (itemDragObject.ItemSlot != null)
         {
             if (!SwitchItems(p_targetSlot, itemDragObject.ItemSlot, itemDragObject.Item))
             {
                 DragDropManager.Instance.CancelDragAction();
             }
             DragDropManager.Instance.EndDragAction();
         }
     }
     else if (DragDropManager.Instance.DraggedItem is ShopDragObject)
     {
         ShopDragObject shopDragObject = (ShopDragObject)DragDropManager.Instance.DraggedItem;
         Int32          p_targetSlot2  = p_targetSlot.Index;
         if (p_targetSlot is EquipmentSlot)
         {
             Party         party         = LegacyLogic.Instance.WorldManager.Party;
             EquipmentSlot equipmentSlot = (EquipmentSlot)p_targetSlot;
             Equipment     equipment     = shopDragObject.Item as Equipment;
             Equipment     equipment2    = equipmentSlot.Item as Equipment;
             Int32         num           = 0;
             if (equipmentSlot.Item != null)
             {
                 num++;
             }
             if (equipment != null && equipment.ItemSlot == EItemSlot.ITEM_SLOT_2_HAND && equipment2 != null && equipment2.ItemSlot != EItemSlot.ITEM_SLOT_2_HAND)
             {
                 if (equipmentSlot.Index == 0 && equipmentSlot.Parent.ItemSlots[1].Item != null)
                 {
                     num++;
                 }
                 else if (equipmentSlot.Index == 1 && equipmentSlot.Parent.ItemSlots[0].Item != null)
                 {
                     num++;
                 }
             }
             Int32   num2 = party.Inventory.GetMaximumItemCount() - party.Inventory.GetCurrentItemCount();
             Boolean flag = party.HirelingHandler.HasEffect(ETargetCondition.HIRE_MULE);
             if (flag)
             {
                 num2 += party.MuleInventory.GetMaximumItemCount() - party.MuleInventory.GetCurrentItemCount();
             }
             if (!equipmentSlot.Parent.Inventory.IsItemPlaceableAt(shopDragObject.Item, equipmentSlot.Index) || num > num2)
             {
                 DragDropManager.Instance.CancelDragAction();
                 DragDropManager.Instance.EndDragAction();
                 return;
             }
         }
         else if (p_targetSlot.Item != null && !Consumable.AreSameConsumables(shopDragObject.Item, p_targetSlot.Item))
         {
             p_targetSlot2 = -1;
         }
         shopDragObject.ItemSlot.Parent.DropCallback(m_inventory, p_targetSlot2);
         DragDropManager.Instance.EndDragAction();
     }
     else if (DragDropManager.Instance.DraggedItem is LootDragObject)
     {
         LootDragObject lootDragObject = (LootDragObject)DragDropManager.Instance.DraggedItem;
         Int32          p_targetSlot3  = p_targetSlot.Index;
         if (p_targetSlot.Item != null && !Consumable.AreSameConsumables(lootDragObject.Item, p_targetSlot.Item))
         {
             p_targetSlot3 = -1;
         }
         lootDragObject.ItemSlot.Parent.DropCallback(m_inventory, p_targetSlot3);
         DragDropManager.Instance.EndDragAction();
     }
     else
     {
         DragDropManager.Instance.CancelDragAction();
     }
 }