private void AddSaladIngredientToList(FoodGameObject foodAdded) { SaladIngredients.Add(foodAdded.FoodIngredient); Destroy(foodAdded.gameObject); UpdateSaladRenderer(); OnSaladIngredientsChanged.Invoke(this); }
/// <summary> /// Returns the the holdable item component of an ingredient spawned /// </summary> /// <returns></returns> public override HoldableItem GetHoldableItem() { // Instantiate the food referent prefab FoodGameObject instantiatedFood = Instantiate(ingredientToSpawn.IngredientPrefab, transform.position, ingredientToSpawn.IngredientPrefab.transform.rotation, transform.parent); // Return the holdable item component return(instantiatedFood.GetHoldableItemComponent()); }
private void OnChoppingEnded(Choppable itemChopped) { Debug.Log("End of chop"); // Call the on chop ending event OnChopEnding.Invoke(itemChopped); if (itemChopped.ChopComplete) { Debug.Log("Item chop complete"); FoodGameObject choppedResult = Instantiate(itemChopped.ChoppedIngredient.IngredientPrefab, itemChopped.transform.position, itemChopped.transform.rotation); choppedResult.transform.parent = itemChopped.transform.parent; choppedResult.GetHoldableItemComponent().ToggleRigidBodyKinematic(true); OnChoppableItemUnboarded.Invoke(itemChopped); Destroy(itemChopped.gameObject); } _activeChoppingState = null; }
public override void PlayerDroppedItem(HoldableItem droppedItem, PlayerController playerThatDroppedTheItem) { // If the max ingredients are held in this bowl, then do nothing if (MaxIngredientsHeld()) { return; } // Try and get the dropped item's food game object component FoodGameObject droppedFood = droppedItem.GetComponent <FoodGameObject>(); if (droppedFood != null) { // If the dropped food is bowlable, then add the salad ingredient if (droppedFood.FoodIngredient.IsBowlable) { AddSaladIngredientToList(droppedFood); } } }