Esempio n. 1
0
    //Check for collisions with obstacles, and the ground
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject collisionObject = collision.gameObject;

        if (collisionObject.CompareTag("Bird"))
        {
            //If the bird is red, it is cooked. Gives a bigger hunger boost
            if (collisionObject.GetComponent <SpriteRenderer>().color == Color.red)
            {
                if (Settings.instance.soundEffects)
                {
                    audioSource.Play();
                }
                GameManager.instance.score += 1;
                if (dinoHunger + 35 > 100)
                {
                    dinoHunger = 100;
                }
                else
                {
                    dinoHunger += 35;
                }
            }
            else //If you eat a normal bird, you gain a smaller amount of hunger
            {
                if (Settings.instance.soundEffects)
                {
                    audioSource.Play();
                }
                if (dinoHunger + 10 > 100)
                {
                    dinoHunger = 100;
                }
                else
                {
                    dinoHunger += 10;
                }
            }

            BirdScript bird = collisionObject.GetComponent <BirdScript>();
            bird.SpawnFeathers(true);
            //bird.ReturnBirdToPool();
            Destroy(collisionObject);
        }
    }