Ejemplo n.º 1
0
 public void OnDrop(GameObject m_drag)
 {
     if (DragDropManager.Instance.DraggedItem is ItemDragObject && m_inventory.Npc.StaticData.AllowItemSell)
     {
         ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
         if (itemDragObject.Item != null)
         {
             Consumable consumable = itemDragObject.Item as Consumable;
             if (consumable != null && consumable.Counter > 1)
             {
                 PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.SPLIT_ITEMS, String.Empty, LocaManager.GetText("POPUP_REQUEST_ITEMS_SELL_LABEL"), new PopupRequest.RequestCallback(ItemSellSplitterCallback));
                 PopupRequest.Instance.ItemSplitter.Open(PopupItemSplitter.Mode.SELL, consumable.Counter, consumable, itemDragObject.ItemSlot.Index, m_inventory, -1);
             }
             else if (itemDragObject.Item is Equipment && ((((Equipment)itemDragObject.Item).Prefixes.Count > 0 && ((Equipment)itemDragObject.Item).Suffixes.Count > 0) || ((Equipment)itemDragObject.Item).IsRelic() || !((Equipment)itemDragObject.Item).Identified))
             {
                 m_itemToSell = itemDragObject;
                 PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.CONFIRM_CANCEL, String.Empty, LocaManager.GetText("POPUP_REQUEST_CONFIRM_SELL_ITEM", itemDragObject.Item.Name), new PopupRequest.RequestCallback(SellItemCallback));
             }
             else
             {
                 itemDragObject.ItemSlot.Parent.Inventory.SellItem(itemDragObject.Item, itemDragObject.ItemSlot.Index, 1);
                 DragDropManager.Instance.EndDragAction();
             }
         }
     }
     else
     {
         DragDropManager.Instance.CancelDragAction();
     }
 }
Ejemplo n.º 2
0
 private void SellItemCallback(PopupRequest.EResultType p_result, String p_inputString)
 {
     if (p_result == PopupRequest.EResultType.CONFIRMED)
     {
         m_itemToSell.ItemSlot.Parent.Inventory.SellItem(m_itemToSell.Item, m_itemToSell.ItemSlot.Index, 1);
     }
     DragDropManager.Instance.EndDragAction();
     m_itemToSell = null;
 }
Ejemplo n.º 3
0
 private void OnDrop(GameObject m_drag)
 {
     if (UICamera.currentTouchID == -1 && DragDropManager.Instance.DraggedItem is ItemDragObject)
     {
         ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
         String         text           = LocaManager.GetText("POPUP_REQUEST_ITEM_THROW_AWAY", itemDragObject.Item.Name);
         PopupRequest.Instance.OpenRequest(PopupRequest.ERequestType.CONFIRM_CANCEL, String.Empty, text, new PopupRequest.RequestCallback(OnRequestCallback));
         DragDropManager.Instance.DelayDragResolve();
     }
 }
Ejemplo n.º 4
0
 private void OnRequestCallback(PopupRequest.EResultType p_result, String p_text)
 {
     if (p_result == PopupRequest.EResultType.CONFIRMED)
     {
         ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
         LegacyLogic.Instance.EventManager.InvokeEvent(itemDragObject.Item, EEventType.INVENTORY_ITEM_DUMPED, EventArgs.Empty);
         DragDropManager.Instance.EndDragAction();
         AudioController.Play("SOU_ANNO4_Item_Destroy");
     }
     else
     {
         DragDropManager.Instance.CancelDragAction();
     }
 }
Ejemplo n.º 5
0
 public virtual void ChangeInventory(IInventory p_inventory)
 {
     if (DragDropManager.Instance.DraggedItem is ItemDragObject)
     {
         ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem;
         if (itemDragObject.ItemSlot.Parent == this)
         {
             DragDropManager.Instance.CancelDragAction();
         }
     }
     m_inventory = p_inventory;
     if (m_itemSlots.Length != m_inventory.GetMaximumItemCount())
     {
         m_itemSlots = new ItemSlot[m_inventory.GetMaximumItemCount()];
     }
 }
Ejemplo n.º 6
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();
         }
     }
 }
Ejemplo n.º 7
0
 private void OnDrop()
 {
     if (UICamera.currentTouchID == -1)
     {
         if (DragDropManager.Instance.DraggedItem is ItemDragObject)
         {
             Character      selectedCharacter = LegacyLogic.Instance.WorldManager.Party.SelectedCharacter;
             ItemDragObject itemDragObject    = (ItemDragObject)DragDropManager.Instance.DraggedItem;
             if (itemDragObject.ItemSlot != null && !selectedCharacter.DoneTurn && !selectedCharacter.ConditionHandler.CantDoAnything())
             {
                 LegacyLogic.Instance.WorldManager.Party.SelectCharacter(selectedCharacter.Index);
                 Int32     index     = itemDragObject.ItemSlot.Index;
                 Potion    potion    = itemDragObject.Item as Potion;
                 Equipment equipment = itemDragObject.Item as Equipment;
                 PartyInventoryController partyInventoryController = itemDragObject.ItemSlot.Parent.Inventory as PartyInventoryController;
                 if (potion != null && partyInventoryController != null)
                 {
                     partyInventoryController.ConsumeItem(index, selectedCharacter.Index);
                 }
                 if (equipment != null)
                 {
                     Int32 autoSlot = (Int32)selectedCharacter.Equipment.GetAutoSlot(equipment);
                     if (autoSlot >= 0 && selectedCharacter.Equipment.IsItemPlaceableAt(equipment, autoSlot))
                     {
                         EquipCommand p_command = new EquipCommand(selectedCharacter.Equipment, partyInventoryController, selectedCharacter.Equipment.GetItemAt((EEquipSlots)autoSlot), equipment, autoSlot, index);
                         if (LegacyLogic.Instance.UpdateManager.PartyTurnActor.CanDoCommand(p_command, LegacyLogic.Instance.WorldManager.Party.CurrentCharacter))
                         {
                             LegacyLogic.Instance.CommandManager.AddCommand(p_command);
                         }
                     }
                 }
             }
         }
         DragDropManager.Instance.CancelDragAction();
     }
 }
Ejemplo n.º 8
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();
     }
 }