protected override void OnTriggerEnter2D(Collider2D collision) { if (!fed) { if (collision.tag == "ThrowThrough" || collision.tag == "SkewerableObject") { return; } Debug.Log("Skewer collided with " + collision.gameObject); //attack radius is set by the amount of Savory/Umami on the skewer if (ingredientArray != null) { FlavorInputManager flavorInput = collision.gameObject.GetComponent <FlavorInputManager>(); if (flavorInput != null) { Debug.Log("Flavor input of " + collision.gameObject + " not null"); if (flavorCountDictionary[RecipeData.Flavors.Umami] > 0 && !detonating) { detonating = true; SetAOE(); } else { // FEEEED MEEEE flavorInput.Feed(ingredientArray, true); fed = true; Destroy(this.gameObject); //================================= bool fedFavorite = flavorInput.FedFavorite(); if (!fedFavorite && GetMajorityFlavor() == RecipeData.Flavors.Sweet) { GameObject sfx = Instantiate(audioPlayer, transform.position, Quaternion.identity); sfx.GetComponent <PlayAndDestroy>().Play(sweetSFX); } else if (!fedFavorite && GetMajorityFlavor() == RecipeData.Flavors.Spicy) { GameObject sfx = Instantiate(audioPlayer, transform.position, Quaternion.identity); sfx.GetComponent <AudioSource>().volume = 0.5f; sfx.GetComponent <PlayAndDestroy>().Play(spicySFX); } } } //if you hit something (and aren't penetrating) but can't feed it else if (!dropping && !penetrateTargets) { SpawnDropsOnMiss(); } } if (collision.gameObject.tag == "Predator") { CharacterData cd = collision.gameObject.GetComponent <CharacterData>(); cd.DoDamage(1); } if (!penetrateTargets) { Destroy(this.gameObject); } } }
private void OnTriggerEnter2D(Collider2D collision) { AIData aiData = null; //Debug.Log("Explosion collided with " + collision.gameObject); if (ingredientArray != null && collision.tag != "Player") { FlavorInputManager flavorInput = collision.gameObject.GetComponent <FlavorInputManager>(); if (flavorInput != null) { flavorInput.Feed(ingredientArray, true); } } if (flavorCountDictionary[RecipeData.Flavors.Umami] > 0 && collision.tag != "Player") { Rigidbody2D rb = collision.GetComponent <Rigidbody2D>(); aiData = collision.GetComponent <AIData>(); if (rb != null) { Vector2 forceVector = (collision.transform.position - transform.position).normalized * flavorCountDictionary[RecipeData.Flavors.Umami] * 1.5f; rb.AddForce(forceVector, ForceMode2D.Impulse); if (aiData != null) { aiData.updateBehavior = false; } } } StartCoroutine(Explode(aiData)); }
/// <summary> /// Deactivates detected drop and destroys it /// </summary> public bool Feed(GameObject drop) { //Debug.Log("Feed Reached"); if (drop != null) { #region Eat AnimatorBody.Play("Feed"); AiData.currentBehavior = AIData.Behave.Feed; IngredientData ingredient = drop.GetComponent <SkewerableObject>().data; AiData.Stomach.Enqueue(ingredient); IngredientData[] ingredientArray = new IngredientData[1]; ingredientArray[0] = ingredient; // activate flavor input manager flavor.Feed(ingredientArray, false); // deactivate drop drop.SetActive(false); Destroy(drop); #endregion AiData.InstantiateSignal(0.1f, "Hunger", -0.1f, false, true); if (AiData.eatingParticleBurst != null) { AiData.eatingParticleBurst.Play(); } if (AiData.eatSFX != null) { Instantiate(AiData.sfxPlayer, transform.position, transform.rotation).GetComponent <PlayAndDestroy>().Play(AiData.eatSFX); //Debug.Log("===========================Hunger sound effect playing here"); } return(true); } else { return(false); } }