private void OnCollisionEnter(Collision collision) { if (this.ingredient == null && collision.gameObject.CompareTag("RecipeIngredient")) { this.GetComponent <InteractableObject>().MaterialTintOverride = Color.red; if (gameObject.transform.position.y < collision.transform.position.y) { print(gameObject.name + " is below " + collision.gameObject.name); this.ingredient = collision.gameObject; RecipeItemObject recipeInteraction = this.ingredient.GetComponent <RecipeItemObject>(); recipeInteraction.optionalPlate = this.gameObject; if (!this.ingredient.name.Contains("bottomBun")) { InteractableObject interactableObject = this.GetComponent <InteractableObject>(); interactableObject.MaterialTintOverride = Color.red; } else if (this.ingredient.name.Contains("bottomBun")) { InteractableObject interactableObject = this.GetComponent <InteractableObject>(); interactableObject.MaterialTintOverride = Color.blue; } } } }
private void OnCollisionExit(Collision collision) { if (collision.gameObject.CompareTag("RecipeIngredient")) { this.GetComponent <InteractableObject>().MaterialTintOverride = null; if (this.ingredient == collision.gameObject) { print(this.ingredient.name + " is no longer above " + this.gameObject.name); RecipeItemObject recipeInteraction = this.ingredient.GetComponent <RecipeItemObject>(); recipeInteraction.stopCookingIngredient(); this.ingredient = null; } } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("RecipeIngredient")) { this.GetComponent <InteractableObject>().MaterialTintOverride = Color.red; if (gameObject.transform.position.y < collision.transform.position.y) { print(gameObject.name + " is below " + collision.gameObject.name); this.ingredient = collision.gameObject; RecipeItemObject recipeInteraction = this.ingredient.GetComponent <RecipeItemObject>(); recipeInteraction.startCookingIngredient(); } } }
private bool validateBurger(GameObject recipeItem, int index, List <string> recipe) { if (index >= recipe.Count) { return(true); } if (recipeItem == null) { return(false); } if (recipe[index] != recipeItem.name) { return(false); } RecipeItemObject recipeInteraction = recipeItem.GetComponent <RecipeItemObject>(); return(validateBurger(recipeInteraction.objectAbove, index + 1, recipe)); }
private GameObject validateBurger(GameObject recipeItem, GameObject plate, int index, List <string> recipe) { if (index < 0) { return(plate); } if (recipeItem == null) { return(null); } print("Item on stack is " + recipeItem.name); if (!recipeItem.name.Contains(recipe[index])) { return(null); } RecipeItemObject recipeInteraction = recipeItem.GetComponent <RecipeItemObject>(); return(validateBurger(recipeInteraction.objectBelow, recipeInteraction.optionalPlate, index - 1, recipe)); }