Ejemplo n.º 1
0
 void Equip(Types.Hand hand)
 {
     if (CanEquip())
     {
         backpack.Add(hand);
         // Give the item the inventory game object to set its parent to
         hand.item.Equip(gameObject);
     }
 }
Ejemplo n.º 2
0
 public static Item GetActiveItem(InventorySystem inventory)
 {
     Types.Hand hand = GetActiveHand(inventory);
     if (hand == null)
     {
         return(null);
     }
     return(hand.item);
 }
Ejemplo n.º 3
0
    void PickUpItem()
    {
        // Grab height of the game object. This will help us scan for objects "in front of us"
        float objectHeight = transform.lossyScale.y;

        // Find any colliders within the weapon's range. Note: for the starting position, we're starting from the height's middle point.
        Collider[] hitColliders = Physics.OverlapSphere(new Vector3(transform.position.x, transform.position.y + (objectHeight / 2), transform.position.z), pickUpRange);
        int        i            = 0;

        while (i < hitColliders.Length)
        {
            Collider col = hitColliders[i];
            if (col.tag == "Item")
            {
                // Grab the weapon script on our found melee weapon
                Types.Hand foundItem = new Types.Hand(col.gameObject);
                Debug.Log(foundItem);
                Equip(foundItem);
            }
            i++;
        }
    }