示例#1
0
    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);
            }
        }
    }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     flavors      = fruitant.GetComponent <FlavorInputManager>();
     bubbleRender = GetComponent <SpriteRenderer>();
     fruitRender  = fruitDisplay.GetComponent <SpriteRenderer>();
     player       = GameObject.FindGameObjectWithTag("Player");
 }
    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));
    }
示例#4
0
 private void Start()
 {
     #region Initialize
     #region GetComponents
     AiData       = GetComponent <AIData>();
     Checks       = AiData.GetComponent <MonsterChecks>();
     AnimatorBody = GetComponent <Animator>();
     RigidBody    = GetComponent <Rigidbody2D>();
     controller   = GetComponent <MonsterController>();
     pathfinder   = GetComponent <Pathfinder>();
     flavor       = GetComponent <FlavorInputManager>();
     sfxPlayer    = GetComponent <PlaySFX>();
     #endregion
     ActionTimer         = -1f;
     ActionTimerReset    = 5f;
     ActionTimerVariance = 2f;
     ResetTimer          = -1f;
     ResetTimerReset     = 6f;
     ResetTimerVariance  = 2f;
     ResetMovementBias();
     #endregion
 }