Ejemplo n.º 1
0
        protected virtual Boolean SwitchItems(ItemSlot p_targetSlot, ItemSlot p_originSlot, BaseItem p_originItem)
        {
            ItemContainer parent = p_originSlot.Parent;
            BaseItem      item   = p_targetSlot.Item;
            Boolean       flag   = parent.Inventory.IsItemPlaceableAt(item, p_originSlot.Index);
            Boolean       flag2  = m_inventory.IsItemPlaceableAt(p_originItem, p_targetSlot.Index);

            if (!flag || !flag2)
            {
                return(false);
            }
            if (!(parent.Inventory is CharacterInventoryController))
            {
                if (!Consumable.AreSameConsumables(p_originItem, item))
                {
                    parent.Inventory.AddItem(item, p_originSlot.Index);
                }
                m_inventory.AddItem(p_originItem, p_targetSlot.Index);
                return(true);
            }
            EquipCommand p_command = new EquipCommand(parent.Inventory, m_inventory, p_originItem, item, p_originSlot.Index, p_targetSlot.Index);

            if (LegacyLogic.Instance.UpdateManager.PartyTurnActor.CanDoCommand(p_command, LegacyLogic.Instance.WorldManager.Party.CurrentCharacter))
            {
                LegacyLogic.Instance.CommandManager.AddCommand(p_command);
                return(true);
            }
            return(false);
        }
 public Int32 GetConsumableSlot(Consumable p_consumable)
 {
     for (Int32 i = 0; i < m_inventory.GetMaximumItemCount(); i++)
     {
         BaseItem itemAt = m_inventory.GetItemAt(i);
         if (Consumable.AreSameConsumables(itemAt, p_consumable))
         {
             return(i);
         }
     }
     return(-1);
 }
        public Int32 GetTotalAmountOfConsumable(Consumable p_consumable)
        {
            Int32 num = 0;

            for (Int32 i = 0; i < m_inventory.GetMaximumItemCount(); i++)
            {
                BaseItem itemAt = GetItemAt(i);
                if (Consumable.AreSameConsumables(itemAt, p_consumable))
                {
                    num += ((Consumable)itemAt).Counter;
                }
            }
            return(num);
        }
Ejemplo n.º 4
0
        public void UpdateItems()
        {
            Boolean flag = !m_initialItemUpdateDone;

            m_initialItemUpdateDone = true;
            if (m_offerData.RefreshType == EOfferRefreshType.DAYBREAK && m_updateTime.Days != LegacyLogic.Instance.GameTime.Time.Days)
            {
                flag = true;
            }
            if (flag)
            {
                m_items.Clear();
                m_updateTime = LegacyLogic.Instance.GameTime.Time;
                foreach (ItemOffer itemOffer in m_offerData.ItemOffers)
                {
                    for (Int32 j = 0; j < itemOffer.ItemQuantity; j++)
                    {
                        BaseItem baseItem = ItemFactory.CreateItem(itemOffer.ItemType, itemOffer.ItemID);
                        Boolean  flag2    = false;
                        foreach (BaseItem baseItem2 in m_items)
                        {
                            flag2 = Consumable.AreSameConsumables(baseItem2, baseItem);
                            if (flag2)
                            {
                                Consumable consumable = (Consumable)baseItem2;
                                consumable.Counter++;
                                break;
                            }
                        }
                        if (baseItem != null && !flag2)
                        {
                            m_items.Add(baseItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
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();
     }
 }