示例#1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (!collider.GetComponent <PlayerMove>())
        {
            return;
        }
        Tunnel t = manager.GetConnectedPortal(this);

        if (t == null)
        {
            return;            // die
        }
        // teleport away
        Vector3 dir = ScreenToWorldVector(t.entryCenter - t.targetCenter, manager.player.cameras[t.targetWindow]);
        Vector3 pos = t.target.transform.position + dir;

        manager.player.SetPosition(t.targetWindow, pos.x, pos.y, pos.z);
        manager.player.SendPlayerMsg(t.targetWindow, t.targetPortalIdx);
        collider.gameObject.SetActive(false);
        manager.LeavingPortal(t.targetPortalIdx);
    }