Example #1
0
    public static bool RemoveItem(
        Script_Item itemToRemove,
        Script_Item[] items,
        Image[] itemImages
        )
    {
        for (int i = 0; i < items.Length; i++)
        {
            if (items[i] == itemToRemove)
            {
                items[i]              = null;
                itemImages[i].sprite  = null;
                itemImages[i].enabled = false;

                return(true);
            }
        }

        return(false);
    }
    public void SetItem(Script_Item item)
    {
        _attachedItem        = item;
        _attachedItem.UIItem = this;
        //Give item color based on type
        switch (item.Type)
        {
        case Script_Item.ItemType.Weapon:
            GetComponent <Image>().color = Color.red;
            break;

        case Script_Item.ItemType.Armor:
            GetComponent <Image>().color = Color.blue;
            break;

        case Script_Item.ItemType.Consumable:
            GetComponent <Image>().color = Color.green;
            break;

        default:
            GetComponent <Image>().color = Color.white;
            throw new ArgumentOutOfRangeException();
        }
    }
    void Awake()
    {
        requiredItem = gardenLightsController.requiredItem;

        ForceLightsOff();
    }
Example #4
0
    // ------------------------------------------------------------------
    // Item Choices
    public bool ShowItemChoices(int itemSlotId, Types type)
    {
        switch (type)
        {
        case Types.Stickers:
            if (GetItemInStickers(itemSlotId))
            {
                return(true);
            }
            break;

        case Types.Items:
            if (GetItemInItems(itemSlotId))
            {
                return(true);
            }
            break;
        }

        Debug.Log("no item in slot");
        ErrorDullSFX();
        return(false);

        bool GetItemInStickers(int itemSlotId)
        {
            if (inventory.GetItemInSlot(itemSlotId))
            {
                // SBook Controller will handle EventSystem, setting active
                Script_Item item = inventory.GetItemInSlot(itemSlotId);
                switch (item)
                {
                case Script_Sticker sticker:
                    itemChoices = stickerChoices;
                    break;

                default:
                    Debug.Log("Error. Did not match a type for this item.");
                    break;
                }

                itemChoices.itemSlotId = itemSlotId;
                itemChoices.SetDropChoice(item.isDroppable);
                sBookController.EnterItemChoices(itemChoices);
                stickersChoicesInputManager.gameObject.SetActive(true);

                return(true);
            }

            return(false);
        }

        bool GetItemInItems(int itemSlotId)
        {
            if (items.GetItemInSlot(itemSlotId))
            {
                // SBook Controller will handle EventSystem, setting active
                Script_Item item = items.GetItemInSlot(itemSlotId);

                Debug.Log($"ITEM IS TYPE: {item.GetType()}");

                switch (item)
                {
                case Script_Collectible collectible:
                    itemChoices = collectibleChoices;
                    break;

                case Script_Usable collectible:
                    itemChoices = usableChoices;
                    break;

                default:
                    Debug.Log("Error. Did not match a type for this item.");
                    break;
                }

                itemChoices.itemSlotId = itemSlotId;
                itemChoices.SetDropChoice(item.isDroppable);
                itemsController.EnterItemChoices(itemChoices);
                itemsChoicesInputManager.gameObject.SetActive(true);

                return(true);
            }

            return(false);
        }
    }
 public ShopEntry(Script_Item item, int price)
 {
     Item  = item;
     Price = price;
 }
Example #6
0
 public bool RemoveItem(Script_Item itemToRemove)
 {
     return(Script_InventoryHelpers.RemoveItem(itemToRemove, items, itemImages));
 }
Example #7
0
 public bool AddItemInSlot(Script_Item itemToAdd, int i)
 {
     return(Script_InventoryHelpers.AddItemInSlot(itemToAdd, i, items, itemImages));
 }
Example #8
0
 public bool AddItem(Script_Item itemToAdd)
 {
     return(Script_InventoryHelpers.AddItem(itemToAdd, items, itemImages));
 }