Пример #1
0
    void OnTriggerEnter2D(Collider2D col)
    {
        // Can't called when win or die
        if (win || dead || translating)
        {
            return;
        }

        // Stop jump
        // if (col.gameObject.tag == "Ground")
        // {
        //     if (falling)
        //  {
        //      FallingState(false);
        //  }
        // }

        // Get key
        if (col.gameObject.tag == "Key")
        {
            bag.AddItem(col.gameObject.GetComponent <Key>());

            // Sound
            soundManager.PlayOnce("get");
        }

        // Get jewellary
        if (col.gameObject.tag == "Jewellary")
        {
            bag.AddItem(col.gameObject.GetComponent <Jewellary>());

            // Sound
            soundManager.PlayOnce("get");
        }

        // Checkpoint
        if (col.gameObject.tag == "Checkpoint")
        {
            BinaryCharacterSaver saver = GameObject.FindObjectOfType(typeof(BinaryCharacterSaver)) as BinaryCharacterSaver;
            saver.Checkpoint(col.gameObject.transform.GetSiblingIndex(), bag);
            // Destroy(col.gameObject);
            col.gameObject.SetActive(false);

            // Sound
            soundManager.PlayOnce("get");
        }

        // Reach destination
        if (col.gameObject.tag == "EndPoint")
        {
            CollideWithGoal(col, true);
        }

        // Reach red room
        if (col.gameObject.tag == "RedRoom")
        {
            CollideWithRedDoor(col, true);
        }

        // Die directly
        if (col.gameObject.tag == "Damagable")
        {
            Die();
        }
    }