예제 #1
0
        public void LoadLocation(int locationId)
        {
            LauncherErrorManager.Instance.Hide();
            Contexts.sharedInstance.game.DestroyAllEntities();
            _isConnecting = true;

            if (LoaderAnime != null)
            {
                LoaderAnime.StartLoaderAnimation();
            }


            LogFeedback(LanguageManager.Instance.GetTextValue("SCENE_LOADING"));

            LoaderSystems loaderSystems = new LoaderSystems(Contexts.sharedInstance);

            loaderSystems.Initialize();
            WorldDataListener.OnUpdate = () => loaderSystems.Execute();
            DataAdapter.LoadObjects();

            SceneLoaderSystem
                sceneLoader =
                new SceneLoaderSystem(Contexts.sharedInstance,
                                      null,
                                      locationId);

            sceneLoader.Initialize();
        }
        public void LoadConfigurationLocation(int locationId)
        {
            _lastLocationId = locationId;

            SceneLoaderSystem sceneLoaderSystem =
                new SceneLoaderSystem(Contexts.sharedInstance, null, locationId);

            sceneLoaderSystem.Initialize();
        }
예제 #3
0
        private void LoadConfigurationFromTar(int worldConfigurationId)
        {
            LoaderAnime.StartLoaderAnimation();
            LoaderSystems loaderSystems = new LoaderSystems(Contexts.sharedInstance);

            loaderSystems.Initialize();
            WorldDataListener.OnUpdate = () => loaderSystems.Execute();
            int worldLocationId;

            DataAdapter.LoadObjects();
            WorldDataListener.Instance.LoadWorldConfiguration(worldConfigurationId, out worldLocationId);
            int locationId = WorldData.WorldStructure.WorldLocations.GetWorldLocation(worldLocationId).LocationId;

            SceneLoaderSystem sceneLoaderSystem =
                new SceneLoaderSystem(Contexts.sharedInstance, null, locationId);

            sceneLoaderSystem.Initialize();
        }
        private void LoadInNullConfigurationLocation(int worldLocationId)
        {
            _logger.Info("Loading location without world configuration...");
            var location = WorldData.WorldStructure.WorldLocations.GetWorldLocation(worldLocationId);

            if (location == null)
            {
                ErrorHelper.DisplayErrorByCode(TM.Errors.ErrorCode.LoadSceneError);
                _logger.Error($"WorldLocationId = {worldLocationId} not exists in  worldId = {WorldData.WorldId}!");
                return;
            }

            if (_lastLocationId != location.LocationId)
            {
                _logger.Info("Other worldLocationId. Need to load scene");
                _lastLocationId = location.LocationId;

                int newWorldLocationId = worldLocationId;
                int oldWorldLocationId = WorldData.WorldLocationId;

                WorldData.OnLoadLocation = delegate
                {
                    Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);
                    WorldData.OnLoadObjects = null;
                };

                SceneLoaderSystem sceneLoaderSystem =
                    new SceneLoaderSystem(Contexts.sharedInstance, null, location.LocationId);
                sceneLoaderSystem.Initialize();
            }
            else
            {
                _logger.Info("Same worldLocationId. Scene alredy loaded");
                LoadObjectsInLoadedLocation(worldLocationId);
            }
        }
        private IEnumerator StopLogicAndLoadSceneCoroutine(int newWorldLocationId, int oldWorldLocationId)
        {
            GameStateData.ClearLogic();

            yield return(new WaitForEndOfFrame());

            GameStateData.ClearObjects();

            if (newWorldLocationId == oldWorldLocationId)
            {
                //Hide everything

                Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);

                LoadWorldDescriptor();

                yield return(new WaitForSeconds(1.0f));

                yield break;
            }

            Debug.Log("Loading loading Scene");

            AsyncOperation loadLoading = SceneManager.LoadSceneAsync("Loading", LoadSceneMode.Additive);

            while (!loadLoading.isDone)
            {
                yield return(null);
            }

            Debug.Log("Unloading old Scene");
            //Hide everything
            // GameStateData.ClearObjects();

            AsyncOperation unloadSceneOperation = SceneManager.UnloadSceneAsync(SceneManager.GetSceneAt(0));

            while (!unloadSceneOperation.isDone)
            {
                yield return(null);
            }

            Resources.UnloadUnusedAssets();

            Debug.Log("Preparing everything");

            GameObjects.Instance.PlayerRig.GetComponentInChildren <VRTK_SDKSetup>().actualBoundaries.transform.position = Vector3.zero;

            WorldData.Update(WorldData.WorldId, newWorldLocationId, WorldData.WorldConfigurationId);
            WorldData.OnLoadObjects    = null;
            WorldData.ObjectsAreLoaded = false;
            Debug.Log("WorldDataListener.StopLogicAndLoadSceneCoroutine()");

            WorldData.OnLoadObjects = delegate
            {
                WorldData.OnLoadLocation = delegate
                {
                    Helper.LoadLocationObjects(newWorldLocationId, oldWorldLocationId);
                };
            };

            int locationId = WorldData.WorldStructure.WorldLocations.GetWorldLocation(newWorldLocationId).LocationId;

            SceneLoaderSystem
                sceneLoader =
                new SceneLoaderSystem(Contexts.sharedInstance,
                                      null,
                                      locationId);

            sceneLoader.Initialize();



            yield return(true);
        }