private void GenerateRecipeItems(int idx)
 {
     currentRecipe = recipes[idx].GetComponent<csRecipe>();
     recipeName.text = currentRecipe.RecipeName;
     recipeImage.sprite = currentRecipe.RecipeImage;
     CreateListItem(currentRecipe.ingredients, ingredientsGrid);
     CreateListItem(currentRecipe.kitchenware, toolsGrid);
 }
Exemplo n.º 2
0
    public void OnDrop(PointerEventData eventData)
    {
        recipe = eventData.pointerDrag.gameObject.GetComponent<csRecipe>();

        if (recipe != null)
        {
            recipe.State = csRecipeStateEnum.None;

            sceneManager.CurrentRecipe = recipe;

            txtMaxSteps.text = recipe.Steps.ToString();
            txtCurrentStep.text = CurrentStep.ToString();

            steps = new csStep[recipe.Steps];

            recipeUI = GameObject.Find("RecipeUI");
            recipeUICanvas = recipeUI.GetComponent<CanvasGroup>();
            recipeUICanvas.alpha = 1;
            recipeUICanvas.blocksRaycasts = true;
            recipeUICanvas.interactable = true;

            imgRecipe = GameObject.Find("imgRecipe");
            imgRecipe.GetComponent<Image>().sprite = recipe.RecipeImage;

            recipeName = GameObject.Find("txtRecipeName");
            recipeName.GetComponent<Text>().text = recipe.RecipeName;

            ClearGrids();

            var ingredients = recipe.ingredients;
            LoadRecipeItems(ingredients, "Prefabs/Ingredients/", ingredientsGrid, ValidateIngredient);

            var kitchenware = recipe.kitchenware;
            LoadRecipeItems(kitchenware, "Prefabs/Kitchenware/", kitchenwareGrid, ValidateKitchenware);

            LoadKitchenWare();

            if(IsMissingKitchenware)
            {
                btnKitchenware.GetComponent<CanvasGroup>().alpha = 1;
                btnKitchenware.GetComponent<CanvasGroup>().interactable = true;
                btnKitchenware.GetComponent<CanvasGroup>().blocksRaycasts = true;
            }

            if(IsMissingIngredients)
            {
                btnIngredients.GetComponent<CanvasGroup>().alpha = 1;
                btnIngredients.GetComponent<CanvasGroup>().interactable = true;
                btnIngredients.GetComponent<CanvasGroup>().blocksRaycasts = true;
            }

            if (!IsMissingIngredients && !IsMissingKitchenware)
            {
                btnCooking.GetComponent<CanvasGroup>().alpha = 1;
                btnCooking.GetComponent<CanvasGroup>().interactable = true;
                btnCooking.GetComponent<CanvasGroup>().blocksRaycasts = true;
            }
        }
    }