Exemple #1
0
    private IEnumerator ReEnableRecipe(RecipeUI recipeUI, float delay)
    {
        recipeUI.gameObject.SetActive(false);

        float time = Time.time;

        yield return(new WaitUntil(() => { if (spawnNewRecipes && Time.time >= time + delay)
                                           {
                                               return true;
                                           }
                                           else
                                           {
                                               return false;
                                           } }));

        for (int i = 0; i < recipeUI.transform.parent.childCount; ++i)
        {
            Transform child = recipeUI.transform.parent.GetChild(i);
            if (recipeUI.transform != child && !child.gameObject.activeSelf)
            {
                recipeUI.transform.SetSiblingIndex(i - 1);
                break;
            }
            else if (i == recipeUI.transform.parent.childCount - 1)
            {
                recipeUI.transform.SetAsLastSibling();
                break;
            }
        }

        recipeUI.SetRecipe(availableRecipes[Random.Range(0, availableRecipes.Count)]);
        recipeUI.gameObject.SetActive(true);
    }
Exemple #2
0
    private void Start()
    {
        List <Recipe> recipes = GameState.instance.GetRestaurant().GetMenu();

        foreach (Recipe recipe in recipes)
        {
            RecipeUI obj = Instantiate(recipeUIPrefab, container);
            obj.SetRecipe(recipe);

            obj.GetButton().onClick.AddListener(() => PrepareRecipe(obj));
            obj.PointerEnter += Obj_PointerEnter;
            obj.PointerExit  += Obj_PointerExit;
        }
    }