//Calls object in hand to use it public void throwHeldItem(Vector2 tarGet) { if (handObject != null) { Timing.RunCoroutine(handObject.GetComponent <Material>().Throw(tarGet, 30).CancelWith(handObject), Segment.FixedUpdate); if (newlyHeldObject == true) { handObject = null; handScript = null; if (itemsInInventory() > 0) { makeHandObject(); } newlyHeldObject = false; } else { //If this was an object in your inventory, update Memento ItemMemento tempMemento = handScript.GetMemento() as ItemMemento; if (tempMemento != null) { tempMemento.setParent(handScript); tempMemento.setInInventory(false, handIndex); } //If object was an object from the inventory, remove it from the inventory Remove(handIndex); } //Update UI UpdateUI(); } }
//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); }