Exemple #1
0
    public void UpdateCraftingMenu(CraftingRecipe selectedRecipe)
    {
        RemoveChildren();
        List <Item> missingItems = thisCrafter.CheckItemsMissing(selectedRecipe);
        List <Item> ownedItems   = thisCrafter.CheckItemsOwned(selectedRecipe);

        foreach (Item missingItem in missingItems)
        {
            GameObject missingItemSlot  = Instantiate(ingredientsPrefab, missingIngredientsPanel.transform);
            Image      missingItemImage = missingItemSlot.GetComponent <Image>();
            missingItemImage.sprite = missingItem.icon;
        }

        foreach (Item ownedItem in ownedItems)
        {
            GameObject ownedItemSlot  = Instantiate(ingredientsPrefab, foundIngredientsPanel.transform);
            Image      ownedItemImage = ownedItemSlot.GetComponent <Image>();
            ownedItemImage.sprite = ownedItem.icon;
        }
        if (missingItems.Count == 0)
        {
            craftButton.interactable = true;
        }
        else
        {
            craftButton.interactable = false;
        }
    }