//This is a secondary add tool used when a PickedUp item is toggled left or right protected bool AddAt(int index, ConcreteItem itemObj) { Item item = itemObj.GetItem(); if (items.Count >= space) { // Send GUI message to Player here (todo), return false. return(false); } // Otherwise we can pick up the item, return true. items.Insert(index, item); //If item has a memento, update it to know the object is now in the players' inventory ItemMemento tempMemento = itemObj.GetMemento() as ItemMemento; if (tempMemento != null) { itemObj.setInInventory(true, handIndex); tempMemento.setParent(null); ItemMementos.Insert(index, tempMemento); } else { ItemMementos.Insert(index, null); } //Create a new ItemBox at index CreateItemBox(index); //Destroy old handObject to make new one if (handObject != null) { Destroy(handObject); } makeHandObject(); return(true); }
protected bool Add(ConcreteItem itemObj) { Item item = itemObj.GetItem(); if (items.Count >= space) { // Send GUI message to Player here (todo), return false. return(false); } // Otherwise we can pick up the item, return true. items.Add(item); ItemMementos.Add(itemObj.GetMemento() as ItemMemento); //Create a new ItemBox at index Count (end of list)-1 to parallel this item added at the end CreateItemBox(items.Count - 1); return(true); }