void DispatchRecipe(int score) { var particles = GameObject.Instantiate(particlesPrefab, spawnPoint.position, spawnPoint.rotation); Destroy(particles.gameObject, 2.0f); currentIngredients.Clear(); DebugIngredients = currentIngredients; for (int c = currentRecipe.childCount - 1; c >= 0; c--) { Ingredient_v2 ingredient = currentRecipe.GetChild(c).GetComponent <Ingredient_v2>(); if (ingredient != null) { ingredient.DispatchRestore(); } else { Debug.Log("The recipe contains a non-ingredient object"); } } if (currentTopping != null) { Destroy(currentTopping); } }
void OnTriggerExit(Collider col) { currentIngredient = col.GetComponent <Ingredient_v2>(); if (currentIngredient != null) { if (currentIngredient.GetComponentInParent <Hand>() != null) // Exits collider and it's attached to a hand, so we remove the handler { currentIngredient.GetComponent <Interactable>().onDetachedFromHand -= HandleIngredientPlaced; } HandleIngredientRemoved(null); } else { if (col.gameObject.layer == LayerMask.NameToLayer("Topping")) { Interactable i = col.GetComponent <Interactable>(); if (i != null) { i.onDetachedFromHand -= HandleToppingPlaced; } currentTopping = null; } } }
void OnTriggerExit(Collider col) { Ingredient_v2 ing = col.GetComponent <Ingredient_v2>(); if (ing != null) { StartCoroutine(Restore(ing)); } }
void Restore(Ingredient_v2 ing) { if (inUseIngsPool.Contains(ing.gameObject)) { inUseIngsPool.Remove(ing.gameObject); ing.gameObject.SetActive(false); ing.gameObject.transform.parent = null; ing.gameObject.transform.position = spawnPoint.position; ing.gameObject.transform.rotation = spawnPoint.rotation; unusedIngsPool.Add(ing.gameObject); } else { Debug.Log("An object restore event arrived for an object that doesn't exist in the spawner's pool of objects..."); } }
void OnTriggerEnter(Collider col) { Ingredient_v2 tmpIngredient = col.GetComponent <Ingredient_v2>(); if (tmpIngredient != null) { currentIngredient = tmpIngredient; if (currentIngredient.GetComponentInParent <Hand>() != null) // Collides and it's attached to a hand, so we wait until it's dropped { Interactable i = currentIngredient.GetComponent <Interactable>(); i.onDetachedFromHand -= HandleIngredientPlaced; // This was added to solve a strange issue that makes OnTriggerEnter execute twice for some ings i.onDetachedFromHand += HandleIngredientPlaced; } else // Collides and it's not attached to a hand, so it's flying via physics or something... { HandleIngredientPlaced(null); } } else { if (col.gameObject.layer == LayerMask.NameToLayer("Topping")) { Interactable i = col.gameObject.GetComponent <Interactable>(); if (i != null) { currentTopping = col.gameObject; i.onDetachedFromHand -= HandleToppingPlaced; // This was added to solve a strange issue that makes OnTriggerEnter execute twice for some ings i.onDetachedFromHand += HandleToppingPlaced; } } } }
IEnumerator Restore(Ingredient_v2 ing) { yield return(new WaitForSeconds(respawnTime)); ing.OutOfRangeRestore(); }
void InitAssembly(Recipe_v2 r) { currentIngredient = null; }