Пример #1
0
 public bool RemoveItem(sItem item)
 {
     if (items.Remove(item)) // if we are able to remove the item from the list, refresh UI and return true
     {
         RefreshUI();
         return(true);
     }
     return(false);
 }
Пример #2
0
        /// <summary>
        /// Refreshes the player inventory
        /// </summary>
        /// <param name="itemArray">Array with the items</param>
        internal void RefreshPouch(sItem[] itemArray)
        {
            bool          updateInventory = false;
            HashSet <int> set             = itemArray.Select(i => i.ItemId).ToHashSet();

            // Our Item pouch has 24 slots
            for (int i = 0; i < 24; i++)
            {
                sItem item = itemArray[i];

                if (!items.ContainsKey(item.ItemId) || !items[item.ItemId].Equals(item))
                {
                    items[item.ItemId] = item;
                    updateInventory    = true;
                }

                set.Remove(item.ItemId);
            }

            // Our Ammo pouch only has 16 slots
            for (int i = 24; i < itemArray.Length; i++)
            {
                sItem item = itemArray[i];

                if (!ammo.ContainsKey(item.ItemId) || !ammo[item.ItemId].Equals(item))
                {
                    ammo[item.ItemId] = item;
                    updateInventory   = true;
                }

                set.Remove(item.ItemId);
            }

            if (set.Count > 0)
            {
                updateInventory = true;
            }

            // Now we clear the dictionary to remove items that are not in our inventory anymore
            foreach (int id in set)
            {
                if (items.ContainsKey(id))
                {
                    items.Remove(id);
                }
                else if (ammo.ContainsKey(id))
                {
                    ammo.Remove(id);
                }
            }

            if (updateInventory)
            {
                OnInventoryUpdate?.Invoke(this, new InventoryUpdatedEventArgs(this));
            }
        }
Пример #3
0
    public override bool CanRecieveItem(sItem item)
    {
        if (item == null)
        {
            return true;
        }

        sEquipment equippableItem = item as sEquipment;
        return equippableItem != null && equippableItem.equipmentType == equipmentType;
    }
Пример #4
0
    public bool AddItem(sItem item) // public method for adding items to the inventory
    {
        if (IsFull())
        {
            return(false);
        }

        items.Add(item);
        RefreshUI();
        return(true);
    }
Пример #5
0
 public bool RemoveItem(sItem _item)
 {
     for (int i = 0; i < moduleItemSlots.Length; i++)
     {
         if (moduleItemSlots[i].item == _item)
         {
             moduleItemSlots[i].item = null;
             return(true);
         }
     }
     return(false);
 }
Пример #6
0
 public void BuyVC(Session p, PacketRead r)
 {
     try
     {
         r.Jump(13);
         uint itemid = r.UInt();
         r.Jump(8);
         int  quantity   = r.Int();
         uint itemuid    = 0;
         int  valuePrice = SelectPrice(itemid);
         if (CheckItemExists(itemid, p) && quantity != -1)
         {
             sItem currentItem = ItemExists(itemid, p);
             itemuid   = currentItem.ItemUID;
             quantity += currentItem.Quantity;
             p.PInventory.UpdateItem(p.PInfo.m_strLogin, itemid, quantity, itemuid);
             p.PInventory.InventoryList.Remove(currentItem);
         }
         else
         {
             itemuid = GetUID();
             p.PInventory.AddItem(p.PInfo.m_strLogin, itemid, quantity, itemuid);
         }
         PacketWrite pw = new PacketWrite();
         pw.Int(BuyException(valuePrice, p));
         pw.Int(1);
         pw.UInt(itemid);
         pw.Int(1);
         pw.UInt(itemuid);
         pw.Int(quantity);
         pw.Int(quantity);
         pw.Short(0);//Epic
         pw.HexArray("00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
         pw.Byte(LoadItemType(itemid));
         pw.HexArray("00 00 00 00 00 00 00 00 00 00 00 00 00 04 FC F7 70 04 FC FF 78 00 00 0D 00 00 00 00 00 00 00 00 00 FF FF FF 9D");
         pw.Int(p.PInfo.m_iVirtualPoint);
         pw.HexArray("00 00 00 00 00 00 01 5E 1C 00 40 47 00 00 00 00");
         p.SendPacket(pw, 396);
     }
     catch
     {
         PacketWrite pw = new PacketWrite();
         pw.Int(1);
         pw.Int(0);
         p.SendPacket(pw, 396);
     }
 }
Пример #7
0
 public void BuyGP(Session p, PacketRead r)
 {
     try
     {
         uint itemid     = r.UInt();
         int  quantity   = r.Int();
         uint itemuid    = 0;
         int  valuePrice = SelectPrice(itemid);
         if (CheckItemExists(itemid, p) && quantity != -1)
         {
             sItem currentItem = ItemExists(itemid, p);
             itemuid   = currentItem.ItemUID;
             quantity += currentItem.Quantity;
             p.PInventory.UpdateItem(p.PInfo.m_strLogin, itemid, quantity, itemuid);
             p.PInventory.InventoryList.Remove(currentItem);
         }
         else
         {
             itemuid = GetUID();
             p.PInventory.AddItem(p.PInfo.m_strLogin, itemid, quantity, itemuid);
         }
         PacketWrite pw = new PacketWrite();
         pw.Int(BuyExceptionGP(valuePrice, p));
         pw.Int(p.PInfo.m_iGamePoint);
         pw.Int(1);
         pw.UInt(itemid);
         pw.Int(1);
         pw.UInt(itemuid);
         pw.Int(quantity);
         pw.Int(quantity);
         pw.Short(0);
         pw.HexArray("00 00 00 00 FF FF FF FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 0C 53 6C A5 B9 73 A2 00 40 37 CC 00 00 0B 00 00 00 00 00 00 00 00 00");
         p.SendPacket(pw, 85);
     }
     catch (Exception ex)
     {
         Log.Write("\n{0}\n{1}\n", ex.Message, ex.StackTrace);
         PacketWrite pw = new PacketWrite();
         pw.Int(1);
         pw.Int(0);
         p.SendPacket(pw, 85);
     }
 }
    private void Drop(ItemSlot dropItemSlot)
    {
        if (dropItemSlot.CanRecieveItem(draggedSlot.item) && draggedSlot.CanRecieveItem(dropItemSlot.item))
        {
            sEquipment dragItem = draggedSlot.item as sEquipment;
            sEquipment dropItem = dropItemSlot.item as sEquipment;

            if (draggedSlot is EquipmentSlot)
            {
                Debug.Log("Equipping " + dropItem.name);
                if (dragItem != null)
                {
                    Unequip(dragItem);                  //dragItem.Unequip(this);
                }
                if (dropItem != null)
                {
                    Equip(dropItem);                  //dropItem.Equip(this);
                }
            }
            if (dropItemSlot is EquipmentSlot)
            {
                if (dragItem != null)
                {
                    Equip(dragItem);                  //dragItem.Equip(this);
                }
                if (dropItem != null)
                {
                    Unequip(dragItem);                  // dropItem.Unequip(this);
                }
            }

            statPanel.UpdateStatValues();

            sItem draggedItem = draggedSlot.item;
            draggedSlot.item  = dropItemSlot.item;
            dropItemSlot.item = draggedItem;
        }
    }
Пример #9
0
 public virtual bool CanRecieveItem(sItem item)
 {
     return(true);
 }