public void OnIngredientAdd(ISubject subject, IIngredient ingredient) { var sideDish = subject as Dish; if (sideDish != null) { for (var i = 0; i < _sideDishesLeft.Count; ++i) { if (sideDish == _sideDishesLeft[i]) { if (_debugLog) { Debug.Log(sideDish + " found"); } for (var j = 0; j < _sideDishesMeshIngredientTypes.Count; ++j) { if (_sideDishesMeshIngredientTypes[j] == ingredient.GetIngredientType()) { if (_debugLog) { Debug.Log(ingredient + " is one of the meshes"); } _sideDishMeshesToEnable[i].Add(_sideDishMeshes[j]); _sideDishesMeshIngredientTypes.RemoveAt(j); _sideDishMeshes.RemoveAt(j); break; } } break; } } } }
public void OnIngredientAdd(ISubject subject, IIngredient ingredient) { for (var i = 0; i < _dishEvents.onDishAddIngredient.Count; ++i) { _dishEvents.onDishAddIngredient[i].TryInvoke(ingredient.GetIngredientType()); } }
public void OnIngredientAdd(ISubject subject, IIngredient ingredient) { for (var i = 0; i < _ingredients.Count; ++i) { if (_ingredients[i] == ingredient.GetIngredientType()) { _ingredients.RemoveAt(i); break; } } if (_ingredients.Count == 0) { dish.ReachRequiredStir(this); } }
private bool TryAddIngredientCheck(IIngredient ingredient) { if (_mustStir && !_currentRequiredStir.HasIngredientType(ingredient.GetIngredientType())) { return(false); } if (_debugLog) { Debug.Log("Trying to add"); } var type = ingredient.GetIngredientType(); if (_finishIngredient != IngredientType.Undefined && type == _finishIngredient) { if (IsFinished(false)) { if (_debugLog) { Debug.Log("Finish ingredient"); } //required ingredient AddFinalIngredientMesh(type, ingredient.GetDishMesh(), ingredient.GetHeight()); InformObserversAddIngredient(ingredient); _finishIngredientPlaced = true; InformObserversFinish(); return(true); } } if (_finishIngredientPlaced) { return(false); } for (var i = 0; i < _requiredIngredients.Count; ++i) { if (type == _requiredIngredients[i]) { if (_debugLog) { Debug.Log("Required ingredient"); } //required ingredient AddIngredientMesh(type, ingredient.GetDishMesh(), ingredient.GetHeight(), true, i); _requiredIngredients.RemoveAt(i); //remove ingredient from the list InformObserversAddIngredient(ingredient); return(true); } } for (var i = 0; i < _optionalIngredients.Count; ++i) { if (type == _optionalIngredients[i]) { if (_debugLog) { Debug.Log("Optional ingredient"); } //required ingredient AddIngredientMesh(type, ingredient.GetDishMesh(), ingredient.GetHeight(), false, i); _optionalIngredients.RemoveAt(i); //remove ingredient from the list InformObserversAddIngredient(ingredient); return(true); } } if (_debugLog) { Debug.Log("Could not be added"); } return(false); }