示例#1
0
    private IEnumerator Connect()
    {
        _portalManager.StartPortalSound();

        yield return(new WaitForSecondsRealtime(2));

        _portalManager.LaunchConnection(this);

        while (_portalManager.Connection != null)
        {
            yield return(null);
        }

        if (Other == null || Exit)
        {
            Deactivate();
            yield break;
        }

        Other.Hero                  = Hero;
        TeleportedRenderer          = Hero.GetComponent <SpriteRenderer>();
        Other.TeleportedLayer       = TeleportedLayer;
        SpriteMaskInteraction       = TeleportedRenderer.maskInteraction;
        Other.SpriteMaskInteraction = SpriteMaskInteraction;

        TeleportedRenderer.maskInteraction = SpriteMaskInteraction.VisibleOutsideMask;

        foreach (var renderer in Hero.GetComponentsInChildren <SpriteRenderer>())
        {
            renderer.maskInteraction = SpriteMaskInteraction.VisibleOutsideMask;
        }

        TeleportedLayer       = Hero.gameObject.layer;
        Hero.gameObject.layer = LayerMask.NameToLayer("Teleported");
        Hero.SetCapeActivation(false);

        _portalManager.StartCoroutine(_portalManager.Teleport(this, Other));
        _connect = null;
    }