Exemple #1
0
        /**
         * <summary>Loads a new scene.  This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand</summary>
         * <param name = "nextSceneInfo">Info about the scene to load</param>
         * <param name = "sceneNumber">The number of the scene to load, if sceneName = ""</param>
         * <param name = "saveRoomData">If True, then the states of the current scene's Remember scripts will be recorded in LevelStorage</param>
         * <param name = "forceReload">If True, the scene will be re-loaded if it is already open.</param>
         * <param name = "_removeNPCID">If non-zero, then an NPC with a Constant ID of this number will be removed after the scene-change</param>
         */
        public void ChangeScene(SceneInfo nextSceneInfo, bool saveRoomData, bool forceReload = false, int _removeNPCID = 0)
        {
            removeNPCID = 0;

            if (!isLoading)
            {
                if (!nextSceneInfo.Matches(thisSceneInfo) || forceReload)
                {
                    if (preloadSceneInfo != null && preloadSceneInfo.IsValid() && !preloadSceneInfo.Matches(nextSceneInfo))
                    {
                        ACDebug.LogWarning("Opening scene '" + nextSceneInfo.GetLabel() + "', but have preloaded scene '" + preloadSceneInfo.GetLabel() + "'.  Preloaded data must be scrapped.");
                        if (preloadAsync != null)
                        {
                            preloadAsync.allowSceneActivation = true;
                        }
                        preloadSceneInfo = null;
                    }

                    removeNPCID = _removeNPCID;

                    PrepareSceneForExit(!KickStarter.settingsManager.useAsyncLoading, saveRoomData);
                    LoadLevel(nextSceneInfo, KickStarter.settingsManager.useLoadingScreen, KickStarter.settingsManager.useAsyncLoading, forceReload);
                }
            }
        }
Exemple #2
0
        /**
         * <summary>Loads a new scene.  This method should be used instead of Unity's own scene-switching method, because this allows for AC objects to be saved beforehand</summary>
         * <param name = "nextSceneInfo">Info about the scene to load</param>
         * <param name = "sceneNumber">The number of the scene to load, if sceneName = ""</param>
         * <param name = "saveRoomData">If True, then the states of the current scene's Remember scripts will be recorded in LevelStorage</param>
         * <param name = "forceReload">If True, the scene will be re-loaded if it is already open.</param>
         * <param name = "_takeNPCPosition">If True, and _revemoNPCID is non-zero, then the Player will teleport to the NPC's position before the NPC is removed</param>
         */
        public void ChangeScene(SceneInfo nextSceneInfo, bool saveRoomData, bool forceReload = false, bool _takeNPCPosition = false)
        {
            takeNPCPosition = false;

            if (!isLoading)
            {
                if (!nextSceneInfo.Matches(thisSceneInfo) || forceReload)
                {
                    if (preloadSceneInfo != null && preloadSceneInfo.IsValid() && !preloadSceneInfo.Matches(nextSceneInfo))
                    {
                        ACDebug.LogWarning("Opening scene '" + nextSceneInfo.GetLabel() + "', but have preloaded scene '" + preloadSceneInfo.GetLabel() + "'.  Preloaded data must be scrapped.");
                        if (preloadAsync != null)
                        {
                            preloadAsync.allowSceneActivation = true;
                        }
                        preloadSceneInfo = null;
                    }

                    takeNPCPosition = _takeNPCPosition;

                    PrepareSceneForExit(!KickStarter.settingsManager.useAsyncLoading, saveRoomData);
                    LoadLevel(nextSceneInfo, KickStarter.settingsManager.useLoadingScreen, KickStarter.settingsManager.useAsyncLoading, forceReload);
                }
            }
            else
            {
                ACDebug.LogWarning("Cannot switch scene while another scene-loading operation is underway.");
            }
        }