Пример #1
0
    /// <summary>
    /// Initialize this menu of dishes.
    /// </summary>
    /// <param name="_gameSceneManager">The GameSceneManager to </param>
    public void InitializeDishMenu(GameSceneManager _gameSceneManager)
    {
        // Start by clearing out all entries in the menu.
        GameObject dishMenuMenuHolder = this.menuHolder;

        dishMenuMenuHolder.DestroyAllChildren();

        // For each dish, instantiate a prefab to represent the dish.
        foreach (Dish dish in _gameSceneManager.GetAcquiredRecipes())
        {
            GameObject instantiatedMenuItem = Instantiate(_gameSceneManager.FOOD_CONTROLLER_PREFAB);
            dishMenuMenuHolder.AddChild(instantiatedMenuItem, false);

            // Then, initialize the script attached to the prefab with information on this GameSceneManager.
            FoodItemController foodItemController = instantiatedMenuItem.GetComponent <FoodItemController>();
            foodItemController.Initialize(dish, _gameSceneManager);
        }

        this.SetDishDetails(this.gameSceneManager.gameState);
    }