public void Equip(Weapons newItem)
 {
     //slotIndex receives the position of the given weapon, if melee, 0, else 1.
     slotIndex = (int)newItem.equipSlot;
     //If there is an item already equipped, add it to the inventory before changing equipped items
     if (currentEquipment[slotIndex] != null)
     {
         aux.element = currentEquipment[slotIndex];
         Inventory.instance.Add(aux);
         aux = new _item();
     }
     //equip the item
     currentEquipment[slotIndex] = newItem;
     playerEquip.UpdateWeapon();
 }
Example #2
0
    //THIS FUNCTION IS CALLED THROUGH THE BUTTON INSPECTOR
    public void Unequip()
    {
        int slotIndex = (int)item.equipSlot;

        if (EquipmentManager.instance.currentEquipment[slotIndex] != null)
        {
            aux.element = EquipmentManager.instance.currentEquipment[slotIndex];
            //Adds the item to the inventory
            Inventory.instance.Add(aux);
            aux = new _item();
            //Removes the item from the array of equipped items
            EquipmentManager.instance.currentEquipment[slotIndex] = null;
            //this.GetComponent<EquipmentManager>().slots[this.GetComponent<EquipmentManager>().slotIndex].ClearSlot();
            //if (EquipmentManager.instance.onItemChangedCallBackEquipped != null)
            //EquipmentManager.instance.onItemChangedCallBackEquipped.Invoke();
            ClearSlot();
            playerEquip.UpdateWeapon();
        }
    }