Exemple #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (HasRope)
        {
            return;
        }

        if (((1 << other.gameObject.layer) & m_RopesToHook.value) != 0)
        {
            Chain NewChain = other.gameObject.GetComponentInParent <Chain>();
            if (NewChain != m_LastChain)
            {
                m_char.ConnectToRopeLink(other);
                HasRope     = true;
                m_LastChain = NewChain;
            }
        }
        else if (((1 << other.gameObject.layer) & m_RopesToCut.value) != 0)
        {
            Debug.Log("cutting");
            other.gameObject.GetComponent <Rigidbody2D>().AddForce(new Vector2(6f, 0), ForceMode2D.Impulse);
            Chain.CutMe(other.gameObject);
        }
    }