Exemple #1
0
 //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();
     }
 }
Exemple #2
0
    //If the object is a one-use, the concreteItem method will call this method to destroy it
    public void destroyHandObject()
    {
        ItemMemento handMemento = handScript.GetMemento() as ItemMemento;

        if (handMemento)
        {
            handMemento.setInInventory(false, 0);
        }
        if (newlyHeldObject == true)
        {
            handScript.Destroy();
            makeHandObject();
            newlyHeldObject = false;
        }
        else
        {
            handScript.Destroy();
            Remove(handIndex);
        }
    }