public void ParseDataRow(string dataRowText) { DRScene model = GameUtility.DeserializeObject <DRScene>(dataRowText); Id = model.Id; AssetName = model.AssetName; BgmId = model.BgmId; }
public static bool InSecene(SceneId sceneId) { IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow((int)sceneId); string sceneAssetName = AssetUtility.GetSceneAsset(drScene.AssetName); return(GameEntry.Scene.SceneIsLoaded(sceneAssetName)); }
/// <summary> /// 获取场景名 /// </summary> /// <param name="sceneComponent"></param> /// <param name="sceneId"></param> /// <returns></returns> public static string GetSceneName(this SceneComponent sceneComponent, int sceneId) { DRScene drScene = sceneComponent.GetDRScene(sceneId); if (drScene != null) { return(drScene.AssetName); } return(""); }
/// <summary> /// 获取场景配置数据 /// </summary> /// <param name="sceneComponent"></param> /// <param name="sceneId"></param> public static DRScene GetDRScene(this SceneComponent sceneComponent, int sceneId) { IDataTable <DRScene> dtScene = GameManager.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow(sceneId); if (drScene == null) { Log.Warning("Can not load scene '{0}' from data table.", sceneId.ToString()); return(null); } return(drScene); }
private float changeSceneDelayTime = 0; // 延迟切换场景时间记录 protected override void OnEnter(ProcedureOwner procedureOwner) { base.OnEnter(procedureOwner); GameEntry.Event.Subscribe(LoadSceneSuccessEventArgs.EventId, OnLoadSceneSuccess); GameEntry.Event.Subscribe(LoadSceneFailureEventArgs.EventId, OnLoadSceneFailure); GameEntry.Event.Subscribe(LoadSceneUpdateEventArgs.EventId, OnLoadSceneUpdate); GameEntry.Event.Subscribe(LoadSceneDependencyAssetEventArgs.EventId, OnLoadSceneDependencyAsset); changeSceneDelayTime = 0; isChangeSceneComplete = false; // 停止所有声音 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(); // 打开LoadingUI //uiLoadingID = GameEntry.UI.OpenUIForm(UIFormId.Loading, this); int sceneId = procedureOwner.GetData <VarInt> (Constant.ProcedureData.NextSceneId).Value; //Debug.Log("id is :"+sceneId); IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene> (); DRScene drScene = dtScene.GetDataRow(1); if (drScene == null) { Log.Warning("Can not load scene '{0}' from data table.", sceneId.ToString()); return; } GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), this); //backgroundMusicId = drScene.BackgroundMusicId; }
private void OnOpenUIFormSuccess(object sender, GameEventArgs e) { OpenUIFormSuccessEventArgs evt = (OpenUIFormSuccessEventArgs)e; if ((UIFormId)evt.UserData == UIFormId.LoadingForm) { int sceneId = ProcedureOwner.GetData <VarInt>(Const.ProcedureDataKey.NextSceneId).Value; IDataTable <DRScene> dtScene = GameManager.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow(sceneId); if (drScene == null) { Log.Warning("Can not load scene '{0}' from data table.", sceneId.ToString()); return; } GameManager.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), this); //m_BackgroundMusicId = drScene.BgmId; } }
protected internal 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(); //读取下一场景ID,根据ID读取场景表中的行数据 m_TargetSceneId = procedureOwner.GetData <VarInt>(Trinity.Constant.ProcedureData.NextSceneId).Value; IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow(m_TargetSceneId); if (drScene == null) { Log.Warning("Can not load scene '{0}' from data table.", m_TargetSceneId.ToString()); return; } //根据行数据里的场景资源名加载场景 GameEntry.Scene.LoadScene(AssetUtility.GetSceneAsset(drScene.AssetName), Trinity.Constant.AssetPriority.SceneAsset, this); m_BackgroundMusicId = drScene.BackgroundMusicId; }
private int m_BackgroundMusicId = 0; //切换场景时的背景音乐 //流程进入回调 public override void OnEnter(IFsm <IProcedureManager> 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_ChangeToMenu = sceneId == MenuSceneId; //是否切换到菜单场景 IDataTable <DRScene> dtScene = GameEntry.DataTable.GetDataTable <DRScene>(); DRScene drScene = dtScene.GetDataRow(sceneId); if (drScene == null) { HotLog.Warning("Can not load scene '{0}' from data table.", sceneId.ToString()); return; } //加载场景 GameEntry.Scene.LoadScene(RuntimeAssetUtility.GetSceneAsset(drScene.AssetName), RuntimeConstant.AssetPriority.SceneAsset, this); m_BackgroundMusicId = drScene.BackgroundMusicId; }
public SceneData(DRScene dRScene, DRAssetsPath dRAssetsPath) { this.dRScene = dRScene; this.dRAssetsPath = dRAssetsPath; }