public bool containsItem(InventoryItem [,] i, InventoryItem it) { foreach(InventoryItem itt in i) { if(it.Equals(itt)) { return true; } } return false; }
public bool containsItem(InventoryItem [,] i, InventoryItem it) { foreach (InventoryItem itt in i) { if (it.Equals(itt)) { return(true); } } return(false); }
/* * public bool addItemFromBox(InventoryItem i) * { * for (int x = 0; x < items.GetLength(0); x++) * { * for (int y = 0; y < items.GetLength(1); y++) * { * Vector2 itemCenter = i.getCenter(); * itemCenter.X -= this.x; * itemCenter.Y -= this.y; * * if (itemRectangles[x, y].Contains(itemCenter) && (items[x, y] == null || (items[x, y] != null && !items[x, y].Equals(i)))) * { * if (items[x, y] == null) * { * items[x, y] = i; * i.setX(itemRectangles[x, y].X); * i.setY(itemRectangles[x, y].Y); * return true; * } * else * { * } * * } * } * } * return false; * * }*/ public void removeItem(InventoryItem i) { for (int x = 0; x < items.GetLength(0); x++) { for (int y = 0; y < items.GetLength(1); y++) { if (i.Equals(items[x, y])) { items[x, y] = null; return; } } } }
public void returnItemToSlot(InventoryItem i) { for (int x = 0; x < items.GetLength(0); x++) { for (int y = 0; y < items.GetLength(1); y++) { if (i.Equals(items[x, y])) { i.setX(itemRectangles[x, y].X); i.setY(itemRectangles[x, y].Y); return; } } } }
/* public bool addItemFromBox(InventoryItem i) { for (int x = 0; x < items.GetLength(0); x++) { for (int y = 0; y < items.GetLength(1); y++) { Vector2 itemCenter = i.getCenter(); itemCenter.X -= this.x; itemCenter.Y -= this.y; if (itemRectangles[x, y].Contains(itemCenter) && (items[x, y] == null || (items[x, y] != null && !items[x, y].Equals(i)))) { if (items[x, y] == null) { items[x, y] = i; i.setX(itemRectangles[x, y].X); i.setY(itemRectangles[x, y].Y); return true; } else { } } } } return false; }*/ public void removeItem(InventoryItem i) { for (int x = 0; x < items.GetLength(0); x++) { for (int y = 0; y < items.GetLength(1); y++) { if(i.Equals(items[x,y])) { items[x, y] = null; return; } } } }