private void RemoveItem(Item itemToRemove, CharacterItemsList shopList) { //Debug.Log(itemToRemove.name + "removed"); for (int i = shopList.itemsList.Count - 1; i >= 0; i--) { if (shopList.itemsList[i] == itemToRemove) { if (itemToRemove.stackable == true) { if (shopList.ItemAndStackNumber(itemToRemove).y > 1) { shopList.DecItemStackNumber(itemToRemove); } else { shopList.RemoveItemFromStack(itemToRemove); shopList.itemsList.RemoveAt(i); } } else { shopList.RemoveItemFromStack(itemToRemove); shopList.itemsList.RemoveAt(i); break; } } } }
void AddItem(Item itemToAdd, CharacterItemsList shopList) { //Debug.Log(itemToAdd.name + "added"); if (shopList.itemsList.Contains(itemToAdd) && itemToAdd.stackable == true) { if (shopList.ContainsItemInStack(itemToAdd)) { shopList.IncItemStackNumber(itemToAdd); } else { shopList.AddItemToStack(itemToAdd); shopList.IncItemStackNumber(itemToAdd); } } else { shopList.itemsList.Add(itemToAdd); shopList.AddItemToStack(itemToAdd); } }