예제 #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ball")
        {
            // Play sounds.
            if (blocking)
            {
                audioSource.PlayOneShot(blockHitSound, 1);
            }
            else
            {
                audioSource.PlayOneShot(crabHitSound, 1);
            }

            RegularBall otherBall = collision.gameObject.GetComponent <RegularBall>();

            if (!blocking && otherBall.isPowered())
            {
                alive = false;
            }
        }
    }
예제 #2
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ball")
        {
            // TODO: play audio here.

            RegularBall otherBall = collision.gameObject.GetComponent <RegularBall>();
            if (powered || otherBall.isPowered())
            {
                otherBall.powerUp();
                audioSource.PlayOneShot(fastBallHitSound, 1);
            }
            else
            {
                audioSource.PlayOneShot(slowBallHitSound, 1);
            }
        }
        else if (collision.gameObject.tag == "Table")
        {
            audioSource.PlayOneShot(tableHitSound, 1);
        }
    }