コード例 #1
0
        /// <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();
        }
コード例 #2
0
    /// <summary>
    /// 交换两个item
    /// </summary>
    /// <param name="drag">拖拽的</param>
    /// <param name="drop">覆盖的</param>
    public void ChangeGirdItem(InventoryItem drag, InventoryItem drop)
    {
        if (drop.Inventory == null)
        {
            drop.SetInventory(drag.Inventory, drag.count);
            drag.Clear();
        }
        else
        {
            Inventory tempInventory = drop.Inventory;
            int       tempCount     = drop.count;


            drop.SetInventory(drag.Inventory, drag.count);
            drag.SetInventory(tempInventory, tempCount);
        }
    }