예제 #1
0
    /// <summary>
    /// Otherwise do the same thing as MoveItem in inventory Script.
    /// But we need to reconstruct the invetory to the player.
    /// </summary>
    /// <param name="clicked"></param>
    public override void MoveItem(GameObject clicked)
    {
        base.MoveItem(clicked);

        foreach (Slot slot in equipmentSlots)
        {
            Transform equipmentTransform = player.transform.FindChild(slot.name);
            if (equipmentTransform != null)
            {
                EquipmentSlot equipment = equipmentTransform.GetComponent <EquipmentSlot>();

                if (slot.isEmpty && !equipment.IsEmpty())
                {
                    equipment.RemoveItem();
                }
                else if (!slot.isEmpty)
                {
                    if (equipment.IsEmpty() || equipment.Item.Item != slot.CurrentItem.Item)
                    {
                        equipment.SetItem(slot.CurrentItem);
                    }
                }
            }
        }
    }
예제 #2
0
 private void UseEquipmentMenu()
 {
     if (Inventory.IHaveFreeSpaceInInventory())
     {
         Inventory.UnEquipmentItem(uItem.item);
         EquipmentSlot equipmentSlot = (EquipmentSlot)uItem;
         equipmentSlot.RemoveItem();
     }
 }
예제 #3
0
    public void OnClick()
    {
        if (slot1.empty || slot2.empty)
        {
            //Empty
            print("A slot is empty");
        }
        else
        {
            CookingManager.CM.StartCooking(slot1.itemID, slot2.itemID);
            //Not empty
            slot1.DecreaseAmount(1);
            //print("Slot 1 Amount: " + slot1.GetAmount());
            slot2.DecreaseAmount(1);
            //print("Slot 2 Amount: " + slot2.GetAmount());

            //Check if slot1 is empty
            if (!slot1.empty)
            {
                //Check if first item can be added
                if (Inventory.inventory.CanAddItem(slot1.itemID, slot1.GetAmount()))
                {
                    Inventory.inventory.AddItemToInventory(slot1.itemID, slot1.GetAmount());
                    slot1.RemoveItem();
                }
                else
                {
                    //Drop the ingredient
                    GameObject tmp = Instantiate(ItemIDManager.instance.GetItem(slot1.itemID), player.position, Quaternion.identity);
                    tmp.GetComponent <ItemInfo>().amount = slot1.GetAmount();
                }
            }

            //Check if slot2 is empty
            if (!slot2.empty)
            {
                //Check to see if the second item can be added
                if (Inventory.inventory.CanAddItem(slot2.itemID, slot2.GetAmount()))
                {
                    Inventory.inventory.AddItemToInventory(slot2.itemID, slot2.GetAmount());
                    slot2.RemoveItem();
                }
                else
                {
                    //Drop the ingredient
                    GameObject tmp = Instantiate(ItemIDManager.instance.GetItem(slot2.itemID), player.position, Quaternion.identity);
                    tmp.GetComponent <ItemInfo>().amount = slot2.GetAmount();
                }
            }

            CookingManager.CM.CloseIngredientMenu();
        }
    }
예제 #4
0
    /// <summary>
    /// Reconstruct single slot's equipment stats.
    /// </summary>
    /// <param name="clothing"></param>
    private void SetClothing(string clothing)
    {
        EquipmentSlot equipment = player.transform.FindChild(clothing).GetComponent <EquipmentSlot>();
        Slot          slot      = GetSlot(clothing);

        if (slot.isEmpty && !equipment.IsEmpty())
        {
            equipment.RemoveItem();
        }
        else if (!slot.isEmpty)
        {
            if (equipment.Item == null || equipment.Item.Item != slot.CurrentItem.Item)
            {
                equipment.SetItem(slot.CurrentItem);
            }
        }
    }
예제 #5
0
    public void TryToRemoveEquipment(EquipmentSlotType slotType, bool toInventory)
    {
        Equipment curretnEquipment = _currentEquipment[slotType];

        if (curretnEquipment == null)
        {
            return;
        }

        if (toInventory)
        {
            _player.PlayerInventoryController.AddItemToInventory(curretnEquipment);
        }
        EquipmentSlot slot = _player.PlayerEquipmentUI.GetEquipmentSlotByType(slotType);

        slot.RemoveItem();

        _currentEquipment[slotType] = null;
    }