Example #1
0
        public void removeItem(A_Item item, List <A_Item> storage)
        {
            A_Item invItem = storage.Find(x => x.GetType().Name.Equals(item.GetType().Name));

            invItem.itemCount--;
            if (invItem.itemCount <= 0)
            {
                storage.Remove(item);
            }
        }
Example #2
0
 private A_Item returnStack(A_Item item, List <A_Item> storage)
 {
     foreach (A_Item invItem in storage)
     {
         if (invItem.GetType().Name.Equals(item.GetType().Name)) //get first item from stack
         {
             return(invItem);
         }
     }
     return(null);
 }
Example #3
0
        //for items storage
        public void addItem(A_Item item, List <A_Item> storage)
        {
            A_Item invItem = null;

            if (item.stackable)
            {
                invItem = returnStack(item, storage);
            }

            if (invItem != null)
            {
                storage.Find(x => x.GetType().Name.Equals(invItem.GetType().Name)).itemCount++;
            }
            else
            {
                storage.Add(item);
            }
        }