private BaseStory LoadStoryItem(EnumStoryType type) { if (!m_storyTypeDic.ContainsKey(type)) { return(null); } BaseStory s = GetFromLoaded(type); if (s) { return(s); } s = GetFromNewItem(type); if (!s) { return(null); } if (!m_loadedStory.ContainsKey(type)) { m_loadedStory.Add(type, new List <BaseStory>()); } m_loadedStory[type].Add(s); s.name = Util.Format("{0}_{1}", type, m_loadedStory[type].Count.ToString("D2")); return(s); }
private void ShowStoryOnLoadOver(int plotID, EnumStoryType type) { StoryInfo info = ConfigManager.Get <StoryInfo>(plotID); if (!info) { Logger.LogError("story id = {0} connot be loaded please check story_config....", plotID); return; } //如果当前已经有了globalBarState,则不在缓存 if (m_globalBarState < 0) { m_globalBarState = moduleGlobal.GetGlobalLayerShowState(); moduleGlobal.ShowGlobalLayerDefault(2, false); } BaseStory story = LoadStoryItem(type); if (!story) { Logger.LogError("plotID = {0},type = {1} asset_name = {2} cannot be loaded", plotID, type, StoryConst.THEATRE_STORY_ASSET_NAME); } else { int layer = type == EnumStoryType.NpcTheatreStory || type == EnumStoryType.TheatreStory ? Layers.Dialog : Layers.UI; Util.SetLayer(story.gameObject, layer); moduleNPCDating.AddEventListener(Module_NPCDating.EventAllStoryEnd, OnAllStoryEnd); currentStoryType = type; currentStoryIndex = 0; currentStory = info; story.ShowDialog(plotID, type); Logger.LogInfo($"开始剧情对话 {plotID}"); } }
public static List <string> GetPreLoadAsset(SceneEventInfo info) { List <string> list = new List <string>(); if (!info) { return(list); } SceneEventInfo.SceneEvent e = null; for (int i = 0; i < info.sceneEvents.Length; i++) { e = info.sceneEvents[i]; for (int j = 0; j < e.behaviours.Length; j++) { if (e.behaviours[j].sceneBehaviorType == SceneEventInfo.SceneBehaviouType.StartStoryDialogue) { EnumStoryType type = (EnumStoryType)e.behaviours[j].parameters[1]; list.AddRange(GetPerStoryPreAssets(e.behaviours[j].parameters[0], type)); } } } return(list); }
/// <summary> /// 显示对话 /// </summary> /// <param name="type"></param> /// <param name="plotId"></param> public void ShowDialog(int plotId, EnumStoryType type) { InitData(); SetFastForwardBtnVisible(fastForward); m_playDefalutMusic = true; OnOpenStory(); }
public void DispatchStoryClosed(int storyId, EnumStoryType type) { if (m_inStoryMode == false) { return; } moduleNPCDating.RemoveEventListener(Module_NPCDating.EventAllStoryEnd, OnAllStoryEnd); DispatchModuleEvent(EventStoryClosed, storyId, type); }
private void AddPveCondition(int storyId, EnumStoryType type) { if (!Level.current.isPvE) { return; } Logger.LogInfo("StoryDialogueEnd contition ,story id = {0}", storyId); modulePVEEvent.AddCondition(new SStoryDialogueEndConditon(storyId)); }
private void _ME(ModuleEvent <Module_Story> e) { EnumStoryType type = (EnumStoryType)e.param2; switch (e.moduleEvent) { case Module_Story.EventStoryStart: m_duringTheatryStory = type == EnumStoryType.TheatreStory; break; case Module_Story.EventStoryEnd: m_duringTheatryStory = false; break; } }
public bool DispatchStoryWillEnd(int storyId, EnumStoryType type) { if (m_storyEndCallBack == null) { Debug.Log("DispatchStoryWillEnd failure because callback is null"); return(false); } Action <int> tmp_cb = m_storyEndCallBack; m_storyEndCallBack = null; tmp_cb?.Invoke(storyId); return(true); }
private BaseStory GetFromLoaded(EnumStoryType type) { if (!m_loadedStory.ContainsKey(type) || m_loadedStory[type] == null || m_loadedStory[type].Count == 0) { return(null); } BaseStory story = m_loadedStory[type].GetValue(0); if (story != null && story.gameObject.activeInHierarchy) { Logger.LogWarning("a new story use the avtive BaseStory GameObject of type :[{0}]", type); } return(story); }
public void DispatchStoryStart(int storyId, EnumStoryType type) { m_inStoryMode = true; if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory) { UIManager.SetCameraLayer(Layers.Dialog); } if (type == EnumStoryType.PauseBattleStory) { m_lastCameraCombatShotState = Camera_Combat.enableShotSystem; Camera_Combat.enableShotSystem = false; } DispatchModuleEvent(EventStoryStart, storyId, type); }
public void DispatchStoryEnd(int storyId, EnumStoryType type) { ResetGlobalState(); if (m_inStoryMode == false) { return; } UIManager.SetCameraLayer(Layers.UI); m_inStoryMode = false; if (type == EnumStoryType.PauseBattleStory) { Camera_Combat.enableShotSystem = m_lastCameraCombatShotState; } DispatchModuleEvent(EventStoryEnd, storyId, type); ResetStoryData(); Logger.LogInfo($"剧情对话结束 {storyId}"); //must before addpvecondition moduleGuide.SendFinishStory(storyId); Module_Guide.AddCondition(new StoryEndContition(storyId)); AddPveCondition(storyId, type); //reset debug mode(only editor useable) if (debugStory) { debugStory = false; return; } //第一段对话完毕的时候,需要强制引导进入stageId = 1,GoHome函数内部发送消息,需要等待玩家数据返回后,才可以进入 if (storyId == DEFAULT_STORY_ID) { if (Module_Guide.skipGuide) { moduleLogin.GoHome(); } else { //moduleGlobal.LockUI(); DispatchEvent(Events.SHOW_LOADING_WINDOW); moduleLogin.GoHome(true); } } }
private BaseStory GetFromNewItem(EnumStoryType type) { string assetName = type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory ? StoryConst.THEATRE_STORY_ASSET_NAME : StoryConst.BATTLE_STORY_ASSET_NAME; GameObject prefab = Level.GetPreloadObject <GameObject>(assetName, false); if (prefab == null) { return(null); } Transform newItem = Root.instance.ui.transform.AddNewChild(prefab); newItem.Strech(); newItem.SafeSetActive(true); return(newItem.gameObject.GetComponentDefault(m_storyTypeDic[type]) as BaseStory); }
private void _ShowStory(int plotID, EnumStoryType type, bool unlock = true, Action <int> callback = null) { m_storyEndCallBack = callback; if (unlock) { moduleGlobal.LockUI("", 0, 0, Module_Global.GUIDE_LOCK_PRIORITY); } m_loading = true; Level.PrepareAssets(GetPerStoryPreAssets(plotID, type), (flag) => { m_loading = false; if (!flag || !moduleLogin.loggedIn && !debugStory && !workOffline) // Lost connection before loading complete { moduleGlobal.UnLockUI(Module_Global.GUIDE_LOCK_PRIORITY); Logger.LogError(!flag ? "prepare story assets failed..." : "Module_Story::_ShowStory: Lost connection to server before assets loading complete."); return; } ShowStoryOnLoadOver(plotID, type); moduleGlobal.UnLockUI(Module_Global.GUIDE_LOCK_PRIORITY); }); }
/// <summary> /// 针对不同的模式可能会加载不同的资源 /// </summary> /// <param name="plotId"></param> /// <param name="type">1代表剧场对话,2代表战斗对话</param> /// <returns></returns> public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type) { List <string> list = new List <string>(); switch (type) { case EnumStoryType.TheatreStory: case EnumStoryType.NpcTheatreStory: list.Add(StoryConst.THEATRE_STORY_ASSET_NAME); list.Add(StoryConst.THEATRE_MASK_ASSET_NAME); list.Add(StoryConst.THEATRE_GM_ASSET_NAME); //list.Add(StoryConst.DEFALUT_CONTENT_BG); break; case EnumStoryType.FreeBattleStory: case EnumStoryType.PauseBattleStory: list.Add(StoryConst.BATTLE_STORY_ASSET_NAME); break; } StoryInfo story = ConfigManager.Get <StoryInfo>(plotId); if (story) { //if (type == EnumStoryType.TheatreStory) list.Add("character_render_camera"); //load StoryInfo.StoryItem item = null; for (int i = 0; i < story.storyItems.Length; i++) { if (i > GeneralConfigInfo.sstoryPreLoadNum && GeneralConfigInfo.sstoryPreLoadNum > 0) { break; } item = story.storyItems[i]; #region theatre story if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory) { //npc assets for (int j = 0; j < item.talkingRoles.Length; j++) { NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId); if (npc == null) { continue; } var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID); for (int m = 0; m < npcAssets.Count; m++) { list.Add(npcAssets[m]); } } //texture assets list.Add(item.background); list.Add(item.contentBg); if (!item.playerIconDetail.Equals("PlayerIcon")) { list.Add(item.playerIconDetail); } //model assets if (item.models != null && item.models.Length > 0) { for (int ii = 0; ii < item.models.Length; ii++) { list.Add(item.models[ii].model); } } } #endregion #region common data list.Add(item.effect); if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT)) { list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET); } //music assets if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG)) { list.Add(item.musicData.musicName); } //voice assets list.Add(item.voiceName); //sound effect assets for (int j = 0; j < item.soundEffect.Length; j++) { list.Add(item.soundEffect[j].soundName); } #endregion } } return(list); }
public void DispatchStoryMaskEnd(int storyId, EnumStoryType type) { DispatchModuleEvent(EventStoryMaskEnd, storyId, type); }
public static List <string> GetPerStoryPreAssets(int plotId, EnumStoryType type, int index) { List <string> list = new List <string>(); StoryInfo story = ConfigManager.Get <StoryInfo>(plotId); index += GeneralConfigInfo.sstoryPreLoadNum; if (story) { if (story.storyItems.Length - 1 < index || index < 0) { return(null); } StoryInfo.StoryItem item = story.storyItems[index]; #region theatre story if (type == EnumStoryType.TheatreStory || type == EnumStoryType.NpcTheatreStory) { //npc assets for (int j = 0; j < item.talkingRoles.Length; j++) { NpcInfo npc = ConfigManager.Get <NpcInfo>(item.talkingRoles[j].roleId); if (npc == null) { continue; } var npcAssets = Module_Battle.BuildNpcSimplePreloadAssets(npc.ID); for (int m = 0; m < npcAssets.Count; m++) { list.Add(npcAssets[m]); } } //texture assets list.Add(item.background); list.Add(item.contentBg); if (!item.playerIconDetail.Equals("PlayerIcon")) { list.Add(item.playerIconDetail); } //model assets if (item.models != null && item.models.Length > 0) { for (int ii = 0; ii < item.models.Length; ii++) { list.Add(item.models[ii].model); } } } #endregion #region common data //full screen effect list.Add(item.effect); if (item.effect.Equals(StoryConst.EYE_CLIP_EFFECT)) { list.Add(StoryConst.EYE_GAUSS_MATERIAL_ASSET); } //music assets if (item.musicData.validMusic && !item.musicData.musicName.Equals(StoryConst.STOP_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_CURRENT_MUSIC_FLAG) && !item.musicData.musicName.Equals(StoryConst.RESET_LAST_MUSIC_FLAG) ) { list.Add(item.musicData.musicName); } //voice assets list.Add(item.voiceName); //sound effect assets for (int j = 0; j < item.soundEffect.Length; j++) { list.Add(item.soundEffect[j].soundName); } #endregion } return(list); }
public static void ShowStory(int plotID, EnumStoryType type, bool unlock = true, Action <int> callback = null) { instance._ShowStory(plotID, type, unlock, callback); }