public static SceneType GetSceneTypeBySceneId(this SceneComponent sceneComponent, SceneId sceneId)
        {
            int     id      = (int)sceneId;
            DRScene drScene = GameEntry.DataTable.GetDataTable <DRScene>().GetDataRow(id);

            return((SceneType)drScene.SceneType);
        }
        protected override void OnEnter(ProcedureOwner procedureOwner)
        {
            base.OnEnter(procedureOwner);

            m_IsChangeSceneComplete = false;

            GameEntry.Event.Subscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess);
            GameEntry.Event.Subscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure);
            GameEntry.Event.Subscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate);
            GameEntry.Event.Subscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset);

            // 停止所有声音
            GameEntry.Sound.StopAllLoadingSounds();
            GameEntry.Sound.StopAllLoadedSounds();

            // 隐藏所有实体
            GameEntry.Entity.HideAllLoadingEntities();
            GameEntry.Entity.HideAllLoadedEntities();

            //卸载所有场景
            string[] loadedSceneAssetNames = GameEntry.Scene.GetLoadedSceneAssetNames();
            for (int i = 0; i < loadedSceneAssetNames.Length; i++)
            {
                GameEntry.Scene.UnloadScene(loadedSceneAssetNames[i]);
            }

            //还原游戏速度
            GameEntry.Base.ResetNormalGameSpeed();

            int sceneId = procedureOwner.GetData <VarInt>(Constant.ProcedureData.NextSceneId).Value;

            m_CurLoadedSceneId = (SceneId)sceneId;
            IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>();
            DRScene drScene = dtScene.GetDataRow(sceneId);

            if (drScene == null)
            {
                Log.Warning("Can no load scene '{0}' from data table.", sceneId.ToString());
                return;
            }

            //打开加载进度界面
            GameEntry.UI.OpenUIForm(UIFormId.LoadingForm, sceneId);

            GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), sceneId);

            m_BackgroundMusicId = drScene.BackgroundMusicId;
            m_SceneName         = drScene.SceneName;
            m_PlayerPos         = drScene.PlayerSpawn;
            GameEntry.Scene.SetCurSceneSpawnPos(m_PlayerPos);
        }
Пример #3
0
        protected override void OnEnter(ProcedureOwner procedureOwner)
        {
            base.OnEnter(procedureOwner);

            m_IsChangeSceneComplete = false;

            GameEntry.Event.Subscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess);
            GameEntry.Event.Subscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure);
            GameEntry.Event.Subscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate);
            GameEntry.Event.Subscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset);

            // 停止所有声音
            GameEntry.Sound.StopAllLoadingSounds();
            GameEntry.Sound.StopAllLoadedSounds();

            // 隐藏所有实体
            GameEntry.Entity.HideAllLoadingEntities();
            GameEntry.Entity.HideAllLoadedEntities();

            // 卸载所有场景
            string[] loadedSceneAssetNames = GameEntry.Scene.GetLoadedSceneAssetNames();
            for (int i = 0; i < loadedSceneAssetNames.Length; i++)
            {
                GameEntry.Scene.UnloadScene(loadedSceneAssetNames[i]);
            }

            // 还原游戏速度
            GameEntry.Base.ResetNormalGameSpeed();

            int sceneId = procedureOwner.GetData <VarInt32>("NextSceneId");

            m_ChangeToMenu = sceneId == MenuSceneId;
            IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>();
            DRScene drScene = dtScene.GetDataRow(sceneId);

            if (drScene == null)
            {
                Log.Warning("Can not load scene '{0}' from data table.", sceneId.ToString());
                return;
            }

            GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), Constant.AssetPriority.SceneAsset, this);
            m_BackgroundMusicId = drScene.BackgroundMusicId;
        }