Пример #1
0
        public InventoryStatus GiveItem(ushort pID, ushort pCount = (ushort) 1)
        {
            // 0 = ok, 1 = inv full, 2 = not found
            ItemInfo inf;
            if (DataProvider.GetItemInfo(pID, out inf))
            {
                byte targetSlot;
                if (!Inventory.GetEmptySlot(out targetSlot))
                {
                    return InventoryStatus.Full; //inventory is full
                }

                    Item equip = new Item(0,(uint)this.ID, inf.ItemID, (sbyte)targetSlot);
                    equip.UpgradeStats = new UpgradeStats();
                    equip.Save();
                    Inventory.AddToInventory(equip);
                    Handler12.ModifyInventorySlot(this, targetSlot, 0x24, targetSlot, equip);
                return InventoryStatus.Added;
            }
            else
            {
                return InventoryStatus.NotFound;
            }
        }
Пример #2
0
 public void UnequipItem(Item pEquip, byte destSlot)
 {
     try
     {
         if (pEquip == null)
         {
             Log.WriteLine(LogLevel.Error, "Unequip Failed by Slot {0}", destSlot);
             return;
         }
           this.Inventory.Enter();
           byte sourceSlot = (byte)pEquip.Slot;
         this.Inventory.EquippedItems.Remove(pEquip);
         pEquip.Slot = (sbyte)destSlot;
         pEquip.IsEquipped = false;
         this.Inventory.AddToInventory(pEquip);
         pEquip.Save();
         Handler12.UpdateEquipSlot(this, destSlot, 0x24, (byte)pEquip.ItemInfo.Slot, null);
         Handler12.UpdateInventorySlot(this, sourceSlot, 0x20, destSlot, pEquip);
         this.UpdateStats();
     }
     finally
     {
       this.Inventory.Release();
     }
 }
Пример #3
0
        public void EquipItem(Item pEquip)
        {
            try
            {
                if (pEquip == null) new ArgumentNullException();
                if (!pEquip.IsEquipped || Level > pEquip.ItemInfo.Level) //:Todo Get race
                {
                    Item equip = this.Inventory.EquippedItems.Find(d => d.Slot == pEquip.Slot && d.IsEquipped);
                    if (equip != null)
                    {
                        SwapEquips(pEquip, equip);
                    }
                    else
                        this.Inventory.Enter();

                    byte sourceSlot = (byte)pEquip.Slot;
                    this.Inventory.InventoryItems.Remove(sourceSlot);
                    pEquip.IsEquipped = true;
                    pEquip.Slot = (sbyte)pEquip.Slot;
                    this.Inventory.AddToEquipped(pEquip);
                    pEquip.Save();

                    Handler12.UpdateEquipSlot(this, sourceSlot, 0x24, (byte)pEquip.ItemInfo.Slot, pEquip);
                    Handler12.UpdateInventorySlot(this, (byte)pEquip.ItemInfo.Slot, 0x20, sourceSlot, null);
                    this.UpdateStats();
                }
            }
            finally
            {
               this.Inventory.Release();
            }
        }
Пример #4
0
 public void SwapEquips(Item sourceEquip, Item destEquip)
 {
     try
     {
         this.Inventory.Enter();
         sbyte sourceSlot = sourceEquip.Slot;
         sbyte destSlot = destEquip.Slot;
         this.Inventory.EquippedItems.Remove(sourceEquip);
         this.Inventory.InventoryItems.Remove((byte)destEquip.Slot);
         sourceEquip.Slot = destSlot;
         sourceEquip.IsEquipped = false;
         destEquip.Slot = sourceSlot;
         destEquip.IsEquipped = true;
         this.Inventory.AddToEquipped(destEquip);
         this.Inventory.AddToInventory(sourceEquip);
         sourceEquip.Save();
         destEquip.Save();
         Handler12.UpdateEquipSlot(this, (byte)destSlot, 0x24, (byte)destEquip.ItemInfo.Slot, destEquip);
         Handler12.UpdateInventorySlot(this, (byte)sourceSlot, 0x20, (byte)destSlot, sourceEquip);
         this.UpdateStats();
     }
     finally
     {
      this.Inventory.Release();
     }
 }