/// <summary>
        /// Updates the player inventory:
        /// </summary>
        public void UpdateInventory()
        {
            Armor.Clear();
            ArcaneItems.Clear();
            InventoryItem.Clear();
            Weapons.Clear();

            foreach (var item in _inventory)
            {
                if (item.GameItem is ItemArmor)
                {
                    Armor.Add(item);
                }
                if (item.GameItem is ItemArcane)
                {
                    ArcaneItems.Add(item);
                }
                if (item.GameItem is ItemWeapon)
                {
                    Weapons.Add(item);
                }
                if (item.GameItem is ItemInventory)
                {
                    InventoryItem.Add(item);
                }
            }

            CalculateInventoryValue();
        }
Ejemplo n.º 2
0
 public int Add(int itemId, int amount = 1, WeaponStatUpgrade.Types activeBonus = (WeaponStatUpgrade.Types)(-2))
 {
     if (!this._blacklist.Contains(itemId))
     {
         float         num           = 0f;
         int           maxAmount     = (num != 0f) ? Mathf.FloorToInt(1f / num) : 2147483647;
         InventoryItem inventoryItem = this._usedSlots.LastOrDefault((InventoryItem s) => s._itemId == itemId);
         if (inventoryItem != null)
         {
             this.UpdateContentVersion();
             amount = inventoryItem.Add(amount, false);
         }
         while (amount > 0 && (this._usedSlots.Count < this._slotCount || this._slotCount == 0))
         {
             inventoryItem = new InventoryItem
             {
                 _itemId    = itemId,
                 _maxAmount = maxAmount
             };
             amount = inventoryItem.Add(amount, false);
             this._usedSlots.Add(inventoryItem);
             this.UpdateContentVersion();
         }
         this.UpdateFillIcon();
     }
     return(amount);
 }
Ejemplo n.º 3
0
 public int Add(int itemId, int amount = 1, WeaponStatUpgrade.Types activeBonus = (WeaponStatUpgrade.Types)(-2))
 {
     if (!this._blacklist.Contains(itemId))
     {
         float num = 0f;
         int maxAmount = (num != 0f) ? Mathf.FloorToInt(1f / num) : 2147483647;
         InventoryItem inventoryItem = this._usedSlots.LastOrDefault((InventoryItem s) => s._itemId == itemId);
         if (inventoryItem != null)
         {
             this.UpdateContentVersion();
             amount = inventoryItem.Add(amount, false);
         }
         while (amount > 0 && (this._usedSlots.Count < this._slotCount || this._slotCount == 0))
         {
             inventoryItem = new InventoryItem
             {
                 _itemId = itemId,
                 _maxAmount = maxAmount
             };
             amount = inventoryItem.Add(amount, false);
             this._usedSlots.Add(inventoryItem);
             this.UpdateContentVersion();
         }
         this.UpdateFillIcon();
     }
     return amount;
 }