//////////////////////////////////////////////////// /// <summary> /// Instantiate the ingredient on the given cell with the given type /// </summary> /// <param name="_cell">Where place the ingredient</param> /// <param name="_type">The type of ingredient</param> void InstantiateIngredient(Cell _cell, Ingredient.IngredientType _type) { Ingredient instantiatedIngredient = GameManager.I.GetPoolManager().GetFirstAvaiableObject <Ingredient>(_cell.transform, _cell.GetWorldPosition()); instantiatedIngredient.TileSetup(_type); ingredientsInLevel.Add(instantiatedIngredient); _cell.AddChild(instantiatedIngredient); }
public IngredientDisposition(Ingredient.IngredientType _type, Vector2Int _cellIndex) { Type = _type; CellIndex = _cellIndex; }
void AddIngredient(Ingredient.IngredientType ingredientType) { messageText.DisplayMessage("", null); // You need to be working on a recipie if (currentRecipie == null) { Debug.Log("No current recipie!"); return; } if (GetCurrentStep() == null) { Debug.Log("No current step!"); return; } // Check if you added something WRONG!!! bool recipieContainsIngredient = false; foreach (IngredientAmount requiredIngredient in GetCurrentStep().requiredIngredients) { if (requiredIngredient.ingredient == ingredientType) { recipieContainsIngredient = true; } } if (!recipieContainsIngredient) { messageText.DisplayMessage("Wrong ingredient!", RandomFailString()); RecipieFailed(); return; } if (heat < GetCurrentStep().minHeat) { messageText.DisplayMessage("Not enough heat!", RandomFailString()); RecipieFailed(); return; } if (heat > GetCurrentStep().maxHeat) { messageText.DisplayMessage("Too much heat!", RandomFailString()); RecipieFailed(); return; } // Add ingredient to the dictionary bool addedAlready = false; foreach (IngredientAmount addedIngredient in addedIngredientsThisStep) { if (addedIngredient.ingredient == ingredientType) { addedIngredient.value = addedIngredient.value + 1; } } if (!addedAlready) { IngredientAmount newAmount = new IngredientAmount(); newAmount.ingredient = ingredientType; newAmount.value = 1; addedIngredientsThisStep.Add(newAmount); } CheckRecipieStatus(); SetNewColor(); }