Пример #1
0
 public void SetItem(GameObjects.ItemSlot i)
 {
     if (i.Amount > 1)
     {
         if (i.Amount > 9999)
         {
             int it = i.Amount / 1000;
             if (it > 9999)
             {
                 it = it / 1000;
                 itemName._Label = string.Format("{0:n0}", it) + "M";
             }
             else
             {
                 itemName._Label = string.Format("{0:n0}", it) + "K";
             }
         }
         else
         {
             itemName._Label = string.Format("{0:n0}", i.Amount);
         }
         Vector2 labelSize = itemName.GetSize();
         itemName.OffsetPos.X = (int)((this._Size.X / 2) - (labelSize.X / 2));
     }
     ItemIcon._Texture = i.ItemInSlot.itemtexture;
     _ItemID           = i.ItemInSlot._ID;
     _Show             = true;
 }
Пример #2
0
        public int getItemCount(Enums.ItemID itemType)
        {
            ItemSlot itemSlot = itemSlots.Find(x => x.ItemInSlot._ID == itemType);

            if (itemSlot == null)
            {
                return(0);
            }
            if (itemSlot.ItemInSlot._Stackable)
            {
                return(itemSlot.Amount);
            }
            else
            {
                int count = itemSlots.Count(x => x.ItemInSlot._ID == itemType);
                return(count);
            }
        }
Пример #3
0
        public void AddItem(Enums.ItemID itemType, int amount = 1)
        {
            //find if the item already exists in a slot
            if (itemType == Enums.ItemID.kItemNone)
            {
                return;
            }
            Item itemToAdd = _ItemManager.GetItem(itemType);

            if (itemToAdd == null)
            {
                Console.WriteLine("Error finding itemtype: " + itemType);
                return;
            }


            ItemSlot itemSlot = itemSlots.Find(x => x.ItemInSlot._ID == itemToAdd._ID);

            if (itemSlot != null) //All items stack in the bank. Is there a slot for this one?
            {
                itemSlot.Amount += amount;
            }
            else //Slot not found. crate it
            {
                if (itemSlots.Count < _Capacity) //Bag can only be so full...
                {
                    // create new slot for the item
                    itemSlot = new ItemSlot();
                    //create the item
                    //put item in slot
                    itemToAdd.itemtexture = _ItemManager.GetTexture(itemToAdd);
                    itemSlot.ItemInSlot   = itemToAdd;
                    itemSlot.Amount       = amount;
                    itemSlots.Add(itemSlot);
                    OnItemBanked(itemToAdd._Name);
                }
                else
                {
                    //error adding item message;
                }
            }
        }
Пример #4
0
        public void RemoveItem(Enums.ItemID itemType, int amount = 1)
        {
            List <ItemSlot> itemSlot = itemSlots.FindAll(x => x.ItemInSlot._ID == itemType);

            ReallyRemoveItem(itemSlot, amount);
        }
Пример #5
0
 public void ToInventory(Enums.ItemID id, int amount = 1)
 {
     _InventoryManager.AddItem(id, amount);
     RemoveItem(id, amount);
     OnItemRemoved(_ItemManager.GetItem(id)._Name);
 }
Пример #6
0
 public ItemBundle()
 {
     outputID = Enums.ItemID.kItemNone;
 }
Пример #7
0
        public void AddItem(Enums.ItemID itemType, int amount = 1)
        {
            //find if the item already exists in a slot
            if (itemType == Enums.ItemID.kItemNone)
            {
                return;
            }
            bool dirty     = false;
            Item itemToAdd = _ItemManager.GetItem(itemType);

            if (itemToAdd == null)
            {
                Console.WriteLine("Error finding itemtype: " + itemType);
                return;
            }

            ItemSlot itemSlot = itemSlots.Find(x => x.ItemInSlot._ID == itemToAdd._ID);

            //item stackable, slot not found make one with amount
            //item not stackable, create new slot with it


            //item stackable, slot found. add to it.
            if (itemToAdd._Stackable && itemSlot != null) //item is stackable and a slot for it was found
            {
                itemSlot.Amount += amount;
                dirty            = true;
            }
            else if (itemToAdd._Stackable && itemSlot == null)
            {
                if (itemSlots.Count < this.capacity) //Bag can only be so full...
                {
                    // create new slot for the item
                    itemSlot = new ItemSlot();
                    //create the item
                    //put item in slot
                    itemToAdd.itemtexture = _ItemManager.GetTexture(itemToAdd);
                    itemSlot.ItemInSlot   = itemToAdd;
                    itemSlot.Amount       = amount;
                    itemSlots.Add(itemSlot);
                    dirty = true;
                }
                else
                {
                    //error adding item message;
                }
            }
            else //item not stackable or item not found, create a new slot
            {
                for (int i = 0; i < amount; i++)
                {
                    if (itemSlots.Count < this.capacity) //Bag can only be so full...
                    {
                        // create new slot for the item
                        itemSlot = new ItemSlot();
                        //create the item
                        //put item in slot
                        itemToAdd.itemtexture = _ItemManager.GetTexture(itemToAdd);
                        itemSlot.ItemInSlot   = itemToAdd;
                        itemSlot.Amount       = 1;
                        itemSlots.Add(itemSlot);
                        dirty = true;
                    }
                    else
                    {
                        //error adding item message;
                    }
                }
            }

            if (dirty)
            {
                OnInventoryChanged();
            }
        }
Пример #8
0
 private void TransferToBank(Enums.ItemID itemID, int amt = 1)
 {
     _BankManager.AddItem(itemID, amt);
     RemoveItem(itemID, amt);
 }
Пример #9
0
 public Item GetItem(Enums.ItemID itemType)
 {
     return(ItemList.Find(x => x._ID == itemType));
 }
Пример #10
0
 public Ingredient()
 {
     _ItemID = Enums.ItemID.kItemNone;
     Amount  = 1;
     Name    = "None";
 }
Пример #11
0
 public void AddItem(Enums.ItemID itemID, int amt = 1)
 {
     _InventoryManager.AddItem(itemID, amt);
 }