Ejemplo n.º 1
0
        private ZoneLoadStatus ChangeZone(ZoneData to, bool waitForConnections)
        {
            var from   = Player.Instance.Zone;
            var loader = new ZoneLoadStatus {
                IsDone = false
            };

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

            if (to != null)
            {
                if (to.State == ZoneState.Loaded && !waitForConnections)
                {
                    EnteringLoadedZone(loader, to, from);
                }
                else
                {
                    StartCoroutine(EnteringUnloadedZone(loader, from, to, waitForConnections));
                }
            }
            else
            {
                loader.IsDone = true;
            }

            return(loader);
        }
Ejemplo n.º 2
0
        private IEnumerator EnteringUnloadedZone(ZoneLoadStatus status, ZoneData from, ZoneData to, bool waitForConnections)
        {
            Freeze();

            if (to.State == ZoneState.Unloaded || to.State == ZoneState.Unloading)
            {
                yield return(LoadZone(to));
            }

            while (to.State == ZoneState.Loading)
            {
                yield return(null);
            }

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

            EnteringZone(to, from);
            status.IsDone = true;

            Thaw();
        }
Ejemplo n.º 3
0
        private IEnumerator UnloadAssets(ZoneLoadStatus status)
        {
            while (!status.IsDone)
            {
                yield return(null);
            }

            yield return(Resources.UnloadUnusedAssets());
        }
Ejemplo n.º 4
0
 private void EnteringLoadedZone(ZoneLoadStatus status, ZoneData to, ZoneData from)
 {
     StartCoroutine(LoadConnections(to, from));
     EnteringZone(to, from);
     status.IsDone = true;
 }