Beispiel #1
0
    private void GenerateIngredientImages(SO_Dish chosenDish)
    {
        var recipeList = chosenDish.DishRecipe.IngredientsList;
        Dictionary <SO_Tag, List <SO_Tag> > ingredientStepsPair = new Dictionary <SO_Tag, List <SO_Tag> >();

        foreach (var cookingStep in recipeList)
        {
            if (!ingredientStepsPair.ContainsKey(cookingStep.Ingredient))
            {
                ingredientStepsPair[cookingStep.Ingredient] = new List <SO_Tag>();
            }
            ingredientStepsPair[cookingStep.Ingredient].Add(cookingStep.CookingMethod);
        }

        // Generating the ingredientImages and storing them in scriptable objects
        int i = 0;

        foreach (var cookingStep in ingredientStepsPair)
        {
            var ingredientContainer = Instantiate(_IngredientContainerPrefab, _CookingStepsContainer);
            ingredientContainer.Initialize(cookingStep.Key, cookingStep.Value.ToArray());
            _IngredientContainerReferences[i].Reference = ingredientContainer;
            ++i;
        }
    }
    public void InvokeEvent(int idOfPlayerWhoCooked, SO_Dish dish)
    {
        if (!_DishCookedEvents.ContainsKey(idOfPlayerWhoCooked))
        {
            return;
        }

        // Invoking the events specific to one player
        foreach (var dishCookedEvent in _DishCookedEvents[idOfPlayerWhoCooked])
        {
            dishCookedEvent(dish);
        }
    }
Beispiel #3
0
    private void Start()
    {
        foreach (var cookingStation in CookingStation.CookingStations)
        {
            // Subscribing to ingredient cooked event
            cookingStation.IngredientPickedUpEvent += AddCookedIngredient;
        }

        // Initializing the dishes to be prepared
        foreach (var expectedDish in _MatchState.ExpectedDishes)
        {
            DishesBeingPrepared[expectedDish] = new List <CookedIngredient>();
        }

        // Pointing to the dish currently being cooked
        _CurrentDishBeingCooked = DishesBeingPrepared.ElementAt(_IndexOfCurrentDishBeingPrepared).Key;
    }
Beispiel #4
0
    private void UpdateDishStatus()
    {
        // Checking if the dish is prepared
        int       numberOfIngredientsInPot  = 0;
        SO_Recipe recipeOfDishBeingPrepared = _CurrentDishBeingCooked.DishRecipe;

        foreach (var recipeInstruction in recipeOfDishBeingPrepared.IngredientsList)
        {
            foreach (var cookedIngredient in DishesBeingPrepared[_CurrentDishBeingCooked])
            {
                if (cookedIngredient == recipeInstruction)
                {
                    ++numberOfIngredientsInPot;
                    break;
                }
            }
        }

        _NumberOfIngredientsInPlace = numberOfIngredientsInPot;
        _DishCookedEvent.Invoke(_CookingPotOwner.ViewID);

        if (numberOfIngredientsInPot == recipeOfDishBeingPrepared.IngredientsList.Length)
        {
            ++_DishesCooked;
            _DishHasBeenCookedEvent.Invoke();

            // Checking if there are more dishes to be prepared and changing the pointer
            if (_IndexOfCurrentDishBeingPrepared + 2 < DishesBeingPrepared.Count)
            {
                ++_IndexOfCurrentDishBeingPrepared;
                _CurrentDishBeingCooked = DishesBeingPrepared.ElementAt(_IndexOfCurrentDishBeingPrepared).Key;
            }
            else
            {
                // Player has completed all the dishes
                _DishesCompletedEvent.Invoke(_CookingPotOwner.ViewID);
            }
        }
    }