Ejemplo n.º 1
0
        protected override void OnUpdate(ProcedureOwner procedureOwner, float elapseSeconds, float realElapseSeconds)
        {
            base.OnUpdate(procedureOwner, elapseSeconds, realElapseSeconds);

            if (m_Open == false)
            {
                m_Open = true;
                int m_SceneId = procedureOwner.GetData <VarInt>(Constant.CommonKey.NextSceneId).Value;
                IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>();
                DRScene drScene = dtScene.GetDataRow(m_SceneId);
                if (drScene == null)
                {
                    Log.Warning("Can not load scene '{0}' from data table.", m_SceneId.ToString());
                    return;
                }
                var formId = drScene.FormId;
                if (formId > -1)
                {
                    GameEntry.UI.OpenUIForm(formId, this);
                }
                else
                {
                    var nextSceneId = drScene.NextSceneId;
                    procedureOwner.SetData <VarInt>(Constant.CommonKey.NextSceneId, nextSceneId);
                    ChangeState <ProcedureChangeScene>(procedureOwner);
                }
            }
            if (m_Next)
            {
                m_Next = false;
                m_Open = false;
                ChangeState <ProcedureChangeScene>(procedureOwner);
            }
        }
Ejemplo n.º 2
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();

            // 隐藏所有ui
            GameEntry.UI.CloseAllLoadedUIForms();
            GameEntry.UI.CloseAllLoadingUIForms();

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

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

            m_SceneId = procedureOwner.GetData <VarInt>(Constant.CommonKey.NextSceneId).Value;
            IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>();
            DRScene drScene = dtScene.GetDataRow(m_SceneId);

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

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