private void CheckItemForReplace(Item NewItem) { for (int i = 0; i < MyItems.Count; i++) { if (ReplaceItem(NewItem, MyItems[i])) i = MyItems.Count; } }
private bool ReplaceItem(Item Item1, Item Item2) { if (Item1.Name != Item2.Name) return false; Item1.Description = Item2.Description; Item1.MyTexture = Item2.MyTexture; Item1.MyStats = Item2.MyStats; return true; }
public void AddItem(Item NewItem) { // first check to stack item for (int i = 0; i < MyItems.Count; i++) { if (MyItems[i].Name == NewItem.Name) { MyItems[i].Quantity++; HandleAddItemEvent(); return; } } // if no item of type, add to list MyItems.Add (NewItem); HandleAddItemEvent(); }
public void AddItem(Item NewItem) { if (OnAddItem != null) { OnAddItem.Invoke(); } // first check to stack item for (int i = 0; i < MyItems.Count; i++) { if (MyItems[i].Name == NewItem.Name) { MyItems[i].Quantity++; return; } } // if no item of type, add to list MyItems.Add (NewItem); }