Example #1
0
        private IEnumerator EnterUnloadedZone(ZoneLoader loader, ZoneData from, ZoneData to, bool waitForConnections)
        {
            Pause();

            if (to.Status == ZoneStatus.Unloaded || to.Status == ZoneStatus.Unloading)
            {
                yield return(StartCoroutine(LoadZone(to)));
            }

            while (to.Status == ZoneStatus.Loading)
            {
                yield return(null);
            }

            if (waitForConnections)
            {
                yield return(StartCoroutine(LoadConnections(to, from)));
            }
            else
            {
                StartCoroutine(LoadConnections(to, from));
            }

            EnterZone(to, from);
            Unpause();
            loader.IsDone = true;
        }
Example #2
0
        public ZoneLoader ChangeZone(ZoneData to, bool waitForConnections)
        {
            var from   = CurrentZone;
            var loader = new ZoneLoader {
                IsDone = false
            };

            if (from != null)
            {
                LeaveZone(from, to);
            }

            if (to != null)
            {
                if (to.Status == ZoneStatus.Loaded && !waitForConnections)
                {
                    EnterLoadedZone(loader, to, from);
                }
                else
                {
                    StartCoroutine(EnterUnloadedZone(loader, from, to, waitForConnections));
                }
            }
            else
            {
                loader.IsDone = true;
            }

            return(loader);
        }
Example #3
0
        public ZoneLoader TransitionZone(Zone zone, string spawnName, Transition transition, bool waitForConnections)
        {
            var to     = Zones[zone.Scene.Index];
            var loader = new ZoneLoader();

            StartCoroutine(TransitionZone(loader, to, spawnName, transition, waitForConnections));
            return(loader);
        }
Example #4
0
        private IEnumerator TransitionZone(ZoneLoader loader, ZoneData to, string spawnName, Transition transition, bool waitForConnections)
        {
            Player.Instance.Controller.Freeze();

            yield return(StartCoroutine(TransitionManager.Instance.StartTransition(transition)));

            var zoneLoader = ChangeZone(to, false);

            yield return(StartCoroutine(TransitionManager.Instance.ObscureTransition()));

            while (!zoneLoader.IsDone)
            {
                yield return(null);
            }

            var spawn = to.GetSpawnPoint(spawnName);

            Player.Instance.Mover.WarpToPosition(spawn.Position, spawn.Direction, spawn.Layer);

            yield return(StartCoroutine(TransitionManager.Instance.FinishTransition()));

            Player.Instance.Controller.Thaw();
            loader.IsDone = true;
        }
Example #5
0
 private void EnterLoadedZone(ZoneLoader loader, ZoneData to, ZoneData from)
 {
     StartCoroutine(LoadConnections(to, from));
     EnterZone(to, from);
     loader.IsDone = true;
 }