Example #1
0
    public void Equip(Equipment newItem)
    {
        int slotIndex = (int)newItem.equipSlot; //gets the index number of our enum, thus letting us know what type of item it is.

        Equipment oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.Add(oldItem);
        }
        if (onEquipmentChanged != null) // Allows us to update when we change our equipment
        {
            onEquipmentChanged.Invoke(newItem, oldItem);
        }

        currentEquipment[slotIndex] = newItem;
        equipmentUI.UpdateUI();
    }
    public void Equip(Item newItem)
    {
        if (onEquipmentChanged != null)
        {
            onEquipmentChanged.Invoke(newItem);
        }

        int slotIndex = (int)newItem.equipSlot;

        Item oldItem = null;

        if (currentEquipment[slotIndex] != null)
        {
            oldItem = currentEquipment[slotIndex];
            inventory.AddItem(oldItem);
        }

        currentEquipment[slotIndex] = newItem;

        equipmentUI.UpdateUI(newItem, slotIndex);

        switch (newItem.equipSlot)
        {
        case EquipmentSlot.Armor: pDets.ChangeArmor(newItem);
            break;

        case EquipmentSlot.Consumable:  pDets.TakeHeal(200);
            break;

        case EquipmentSlot.Helmet:  pDets.ChangeHelmet(newItem);
            break;

        case EquipmentSlot.Jewellery:   pDets.ChangeJewellery(newItem);
            break;

        case EquipmentSlot.Weapon:  pDets.ChangeWep(newItem);
            break;
        }
    }