public bool CanReplaceItemInSlot(ItemDefinition_SO item_SO)
    {
        if (ItemAllowed.Length == 0 || item_SO == null || item_SO.itemID == -1)
        {
            return(true);
        }

        if (item_SO.itemType == ItemType.Equipment)
        {
            foreach (EquipmentType equipType in equipmentAllowed)
            {
                if (equipType == ((EquipmentDefinition_SO)item_SO).equipmentType)
                {
                    return(true);
                }
            }
        }
        else
        {
            foreach (ItemType itemType in ItemAllowed)
            {
                if (itemType == item_SO.itemType)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
    public ItemDefinition(ItemDefinition_SO item_SO)
    {
        itemID = item_SO.itemID;

        if (item_SO.itemType == ItemType.Equipment)
        {
            EquipmentDefinition_SO equipment_SO = (EquipmentDefinition_SO)item_SO;

            attributes = new ItemAttribute[equipment_SO.attributes.Length];
            for (int i = 0; i < equipment_SO.attributes.Length; i++)
            {
                attributes[i] = new ItemAttribute(equipment_SO.attributes[i].attributeType, equipment_SO.attributes[i].minValue, equipment_SO.attributes[i].maxValue);
            }
        }
    }
 public void ShowItemDescription(ItemDefinition_SO item_SO)
 {
     if (item_SO == null)
     {
         text_ItemName.text        = "";
         text_ItemDescription.text = "";
         text_Price.text           = "";
         button_Buy.SetActive(false);
     }
     else
     {
         text_ItemName.text        = item_SO.itemName.ToString();
         text_ItemDescription.text = item_SO.itemDescription.ToString();
         text_Price.text           = item_SO.price.ToString();
         button_Buy.SetActive(true);
     }
 }
Exemple #4
0
    public void UpdateItemDescriptionUIWhenClickToSlot(GameObject slotObject)
    {
        if (slotObject == null || slotsOnUI[slotObject].item.itemID == -1)
        {
            itemDescriptionUI.text_Name.text        = "";
            itemDescriptionUI.text_Description.text = "";

            UIManager.Instance.playerInventoryUI.itemDescriptionUI.SetActiveButton(false);
        }
        else
        {
            MouseController.clickedSlot = slotsOnUI[slotObject];

            ItemDefinition_SO item_SO = slotsOnUI[slotObject].item_SO;
            itemDescriptionUI.text_Name.text        = item_SO.itemName.ToString();
            itemDescriptionUI.text_Description.text = item_SO.itemDescription.ToString();

            itemDescriptionUI.SetActiveButton(true);
            itemDescriptionUI.SetButtonText(slotsOnUI[slotObject].item_SO.itemType, slotsOnUI[slotObject].parentUI.inventory_SO.inventoryType);
        }
    }