Example #1
0
    private void RawTeleport(Map map, Vector2Int location, OrthoDir?facing = null)
    {
        if (Avatar == null)
        {
            AddInitialAvatar(map);
        }
        else
        {
            Avatar.transform.SetParent(map.objectLayer.transform, false);
        }
        Avatar.GetComponent <MapEvent>().SetPosition(location);
        if (facing != null)
        {
            Avatar.Chara.Facing = facing.GetValueOrDefault(OrthoDir.North);
        }

        if (ActiveMap != null)
        {
            ActiveMap.OnTeleportAway();
            Destroy(ActiveMap.gameObject);
        }

        ActiveMap = map;
        ActiveMap.OnTeleportTo();
        Global.Instance().Dispatch.Signal(EventTeleport, ActiveMap);
        Avatar.OnTeleport();
    }
Example #2
0
    private void RawTeleport(Map map, IntVector2 location)
    {
        Assert.IsNotNull(ActiveMap);
        Assert.IsNotNull(Avatar);

        int layerIndex = Avatar.GetComponent <MapEvent>().LayerIndex;

        Avatar.transform.parent = null;
        Layer parentLayer = map.LayerAtIndex(layerIndex);

        Avatar.transform.parent = parentLayer.gameObject.transform;

        ActiveMap.OnTeleportAway();
        Object.Destroy(ActiveMap.gameObject);
        ActiveMap = map;
        ActiveMap.OnTeleportTo();
        Avatar.GetComponent <MapEvent>().SetLocation(location);
    }
Example #3
0
    private void RawTeleport(Map map, Vector2Int location, OrthoDir?facing = null)
    {
        IsTransitioning = true;
        activeMapName   = null;
        if (Avatar == null)
        {
            AddInitialAvatar(map);
        }
        else
        {
            Avatar.transform.SetParent(map.objectLayer.transform, false);
        }
        Avatar.GetComponent <MapEvent>().SetPosition(location);
        if (facing != null)
        {
            Avatar.Chara.Facing = facing.GetValueOrDefault(OrthoDir.North);
        }

        if (map != ActiveMap)
        {
            if (ActiveMap != null)
            {
                ActiveMap.OnTeleportAway();
                if (ActiveMap.transform.parent != null)
                {
                    DestroyImmediate(ActiveMap.transform.parent.gameObject);
                }
                else
                {
                    DestroyImmediate(ActiveMap.gameObject);
                }
            }

            ActiveMap = map;
            ActiveMap.OnTeleportTo();
            camera        = null;
            Camera.target = Avatar.Event;
            Global.Instance().Dispatch.Signal(EventTeleport, ActiveMap);
            Avatar.OnTeleport();
        }
        StartCoroutine(CoUtils.RunAfterDelay(0.2f, () => {
            IsTransitioning = false;
        }));
    }