Example #1
0
    public void ReactToFood(Collider other)
    {
        //Check if food coming into mouth
        if (other.gameObject.tag == "Food" && Cat.GetComponent <CatController>().Selected == gameObject)
        {
            //set Cat reach animation
            //Cat.GetComponent<Animator>().SetTrigger("Reach");

            //eating animation
            gameObject.GetComponent <Animator>().SetTrigger("Eat");
            Sounds.InvokeBirdGulp();

            //Check if food is correct tone
            if (other.gameObject.GetComponent <Food>().tone != tone)
            {
                Sounds.BirdWrong();

                //spitting animation
                gameObject.GetComponent <Animator>().SetTrigger("Spit");
                Sounds.InvokeBirdSpit();

                Cat.GetComponent <CatController>().MistakeTexture();

                Destroy(other.gameObject);
                ScoreController.Instance.Incorrect(this);
            }
            else
            {
                TutorialBirdFeed();

                Sounds.BirdCorrect();

                //return to idle when done eating
                gameObject.GetComponent <Animator>().SetTrigger("Idle");

                Cat.GetComponent <CatController>().CorrectTexture();

                Destroy(other.gameObject);
                currScore++;
                UpdateScore();

                GameObject clone;

                clone = (GameObject)Instantiate(numberObject, gameObject.transform.position + new Vector3(0, 1, -1), gameObject.transform.rotation);
                clone.transform.LookAt(Camera.main.transform.position);                 //Fixing number orientation
                clone.transform.localScale = new Vector3(-0.1f, 0.1f, 0.1f);            //Fixing number direction
                ScoreController.Instance.Correct(this);
            }

            //Make sure bird not excited anymore
            Cat.GetComponent <CatController>().Selected = null;
            gameObject.GetComponent <Animator>().SetBool("Excite", false);

            Cat.GetComponent <CatController>().holding--;
            Cat.GetComponent <CatController>().Held  = null;
            Cat.GetComponent <CatController>().state = State.Return;
        }
    }