Beispiel #1
0
/******************** Items **********************/
    public bool Equip(Item item)
    {
        if (FreeHands < item.Hands)
        {
            return(false);
        }

        ExpressionResult requierment = item.Requirement.Evaluate(this);

        if (!requierment.Success)
        {
            //ERROR
            Debug.LogError($"Error evaluating item \"{item.Name}\" requirement:\n{requierment.Message}");
            return(false);
        }
        if (requierment.Value == 0)
        {
            return(false);
        }

        EquippedItems.Add(item);
        FreeHands -= item.Hands;
        RefreshModifiers();
        return(true);
    }
Beispiel #2
0
 public void EquipItem(Item item)
 {
     if (EquippedItems.Count < ItemCapacity)
     {
         EquippedItems.Add(item);
     }
 }
Beispiel #3
0
 public void AddToEquipped(Item pEquip)
 {
     try
     {
         locker.WaitOne();
         Item old = EquippedItems.Find(equip => equip.Slot == pEquip.Slot);
         if (old != null)
         {
             old.IsEquipped = false;
             AddToInventory(old);
             EquippedItems.Remove(old);
         }
         EquippedItems.Add(pEquip);
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }
Beispiel #4
0
        public void LoadFull(ZoneCharacter pChar)
        {
            try

            {
                locker.WaitOne();
                DataTable items = null;
                using (var dbClient = Program.CharDBManager.GetClient())
                {
                    items = dbClient.ReadDataTable("SELECT * FROM items WHERE Owner=" + pChar.ID + "");
                }
                //we load all equippeditem

                if (items != null)
                {
                    foreach (DataRow row in items.Rows)
                    {
                        var loaded = Item.LoadItem(row);
                        loaded.Owner        = (uint)pChar.ID;
                        loaded.UpgradeStats = new UpgradeStats();
                        if (loaded.IsEquipped)
                        {
                            loaded.Slot = (sbyte)loaded.ItemInfo.Slot;
                            EquippedItems.Add(loaded);
                        }
                        else
                        {
                            InventoryItems.Add((byte)loaded.Slot, loaded);
                        }
                    }
                }

                //we load inventory slots
                if (items != null)
                {
                    foreach (DataRow row in items.Rows)
                    {
                        var loaded = Item.LoadItem(row);

                        /*  if (loaded.ItemInfo.Class == ItemClass.Rider)
                         * {
                         *    Mount mount = Data.DataProvider.Instance.GetMountByItemID(loaded.ID);
                         *    if (mount != null)
                         *    {
                         *        loaded.Mount = mount;
                         *        loaded.Mount.Food = GetDataTypes.GetUshort(row["fuelcount"]);
                         *        loaded.Mount.ItemSlot = (byte)loaded.Slot;
                         *    }
                         *    this.AddToInventory(loaded);
                         * }
                         * else
                         * {*/
                        AddToInventory(loaded);
                        //}
                    }
                }
            }
            finally
            {
                locker.ReleaseMutex();
            }
        }