예제 #1
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        //Plays audio on collision with objects tagged as Atom
        if (collision.gameObject.CompareTag("Atom"))
        {
            audioClips.AtomGet();
            uI.AddAtom();
            uI.AddToScore(100);
        }

        if (collision.gameObject.CompareTag("FloatingPlatformCollision"))
        {
            floatingPlatform = collision.gameObject.GetComponent <FloatingPlatform>();
            isOnPlatform     = true;
        }

        if (collision.gameObject.CompareTag("Robot") ||
            collision.gameObject.CompareTag("HatchMonster") ||
            collision.gameObject.CompareTag("SmallEnemy"))
        {
            notDead = false;


            if (walkingDirection)
            {
                myAnimator.CrossFade("ElectrocutionRight", 0.0f);
            }
            else
            {
                myAnimator.CrossFade("ElectrocutionLeft", 0.0f);
            }

            audioClips.Electrocution();

            rigidbody2D.velocity = jumpPos;

            transform.collider2D.isTrigger = true;
        }
    }