Пример #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Head" && controllerScript.score <= 0 || other.tag == "Active Hat")
        {
            if (hatActive)
            {
                if (other.tag == "Active Hat")
                {
                    other.tag = "Inactive Hat";
                }

                this.rigidbody2D.gravityScale = 0.0f;
                audio.Play();
                controllerScript.IncreaseScore(1);

                //I'll have a way later on to move the camera only when it reaches the uppermost hat
                //I'll wait for when we test more and decide if we only allow stacking on the topmost hat or allow stacking on other hats visible on screen
                controllerScript.MoveCamera(hatCollider.size.y / 5.2f);
                controllerScript.timeBetweenWaves = 0.0f;

                this.gameObject.rigidbody2D.isKinematic = true;                                               //Stop hat from moving
                this.gameObject.transform.parent        = GameObject.FindGameObjectWithTag("Head").transform; //Parent it to the head

                hatActive = false;
            }
        }
    }