CharacterBehavior.OnTriggerEnter2D C# (CSharp) Method

OnTriggerEnter2D() public method

public OnTriggerEnter2D ( Collider2D other ) : void
other UnityEngine.Collider2D
return void
    public virtual void OnTriggerEnter2D(Collider2D other)
    {
        // If you collide with a checkpoint...
        if (other.gameObject.tag == "checkpoint") {
            // activate it
            activeCheckpoint = other.gameObject;
            for(int i=0; i<currentMats.Length; i++){
                CheckPointMatsCount[i] = currentMats[i];
            }
            //CheckPointMatsCount = currentMats;
            PickUpList.Clear ();
            KilledEnemies.Clear ();
            other.gameObject.GetComponent<BoxCollider2D> ().enabled = false;
            other.gameObject.GetComponent<Checkpoint> ().touched = true;
            if (gameObject != null) {
                AudioSource.PlayClipAtPoint (altarActivateSound, ImpThrowCam.transform.position, 75.0f);
            }
        }
        // If you collide with a crystal...
        if (other.gameObject.tag == "crystal") {
            //play a sound
            if (gameObject != null) {
                AudioSource.PlayClipAtPoint (crystalPickupSound, ImpThrowCam.transform.position, 75.0f);
            }
            // pick it up
            pickUpMat (other.gameObject);
        }
        // If you collide with the end of the stage...
        if (other.gameObject.tag == "Finish") {
            //Add go to next level code here
            if (Application.loadedLevel+1 < Application.levelCount)
            {
                if (Application.loadedLevelName != "OpeningScene")
                {
                    Debug.Log("here");
                    MenuScript.levelNum = Application.loadedLevel + 1;
                }
                Application.LoadLevel("LoadingScreen");
            }
            else
            {
                Application.LoadLevel(0);
            }
        }
        // If you collide with a "hard" object...
        /*if (other.gameObject.tag == "floor" || other.gameObject.tag == "impTrigger" || other.gameObject.tag == "moving") {
            // fall death if you're falling too quickly
            if ( rb.velocity.y <= 0.0f )
            {
                print(rb.velocity.y);
            }
            if (rb.velocity.y <= -25.0f) {
                if (PlayerAnim && !CharacterBehavior.Dying) {
                    PlayerAnim.SetBool ("FallDeath", true);
                    CharacterBehavior.Dying = true;
                }
                //OnDeath ();
            }
        }*/
        // If you collide with a moving platform..
        if (other.gameObject.tag == "moving") {
            // attach the character to it so they move with it
            transform.SetParent (other.transform);
        }
        if (other.gameObject.tag == "cinder") {
            // it's a cinder! it always kills
            if (!CharacterBehavior.Dying){
                PlayerAnim.SetBool ("EnemyDeath", true);
                CharacterBehavior.Dying = true;
            }
            //OnDeath ();
        }
        // If you collide with deadly fog...
        if (other.gameObject.tag == "playerkiller") {
            //die, obviously
            if (!CharacterBehavior.Dying)
            {
                AudioSource.PlayClipAtPoint(playerPlayerFogSound, transform.position);
                PlayerAnim.SetBool("EnemyDeath", true);
                CharacterBehavior.Dying = true;
            }
        }
        // If you collide with imp-killing fog...
        if (other.gameObject.tag == "impkiller") {
            //all of your crystals vanish! bwahahaha!
            BatBehavior isABat = other.gameObject.GetComponent<BatBehavior> ();
            FinalBossBehavior isABoss = other.gameObject.GetComponent<FinalBossBehavior> ();
            if (isABat == null && isABoss == null) {
                for(int i=0; i<currentMats.Length; i++){
                    currentMats[i] = 0;
                }
                AudioSource.PlayClipAtPoint(playerImpFogSound, transform.position);
                return;
            }
        }
    }