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}"); } }
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); }
/// <summary> /// Start executing a given task /// </summary> /// <param name="story"></param> public void Apply(BaseStory story) { //Return null if the tasks given was null if (story == null) { return; } _logger.LogTrace($"Applying task: {story}"); if (_runningStories.ContainsKey(story)) { story.Reset(); } else { //Add the task to the list for updating _runningStories.TryAdd(story, 0); //When the task is finished remove it from the list story.OnFinished += Task_OnFinished; story.OnCancelled += Task_OnFinished; } try { //Run the task asynchronously with the Coordinators cancellation token source and refresh rate story.Start(new CancellationTokenSource(), _refreshRate); } catch (Exception ex) { _logger.LogDebug($"Task Failed: {ex}"); } }
public void Resume(BaseStory story) { if (_runningStories.ContainsKey(story)) { story.Resume(); } }
public void Pause(BaseStory story) { if (_runningStories.ContainsKey(story)) { story.Pause(); } }
public void Stop(BaseStory story) { if (_runningStories.ContainsKey(story)) { story.Cancel(); } }
private void ExtractStoryDataFrom(ref string line, ref BaseStory result) { if (line.ReferTo("NAME: ")) { result.Header.Name = SetValueFrom(line); } if (line.ReferTo("ONETIMESTORY: ")) { result.Header.CanBePlayedOnlyOnce = SetOneTimeStoryFrom(line); } if (line.ReferTo("DEPENDON: ")) { result.Header.DependOn = SetValueFrom(line); } if (line.ReferTo("TIME: ")) { result.Header.Time = SetTimeFrom(line); } if (line.ReferTo("STORYTYPE: ")) { result.Header.TypeOfStory = SetStoryTypeFrom(line); } if (line.ReferTo("RESTRICTION: ")) { result.Restrictions.Add(ExtractEvaluationFrom(line)); } }
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); }
private void OnStoryStepChange(FrameData d) { int storyId = d.parameters.GetValue <int>(0); int storyIndex = d.parameters.GetValue <int>(1); EnumContextStep step = (EnumContextStep)d.parameters.GetValue <int>(2); BaseStory story = moduleStory.GetCurrentValidStory(); if (!story) { Logger.LogWarning("there is no active story...please check out data is [id = {0},index = {1} step = {2}]"); return; } story.RecvFrameData(storyId, storyIndex, step); }
public IStory ImportFrom(string[] story) { if (!story[0].ReferTo("STORY")) { return(null); } story = story.RemoveEmptyItems(); story = story.RemoveSpecialCharacters(); var result = new BaseStory(); for (var i = 0; i < story.Length; i++) { while (!StoryIsFullyExtracted(story[i])) { if (!story[i].ReferTo("ACT") && !story[i].ReferTo("SEQUENCE")) { MovePointerForward(story, ref i); } if (story[i].ReferTo("ACT")) { var act = ExtractActFrom(story, ref i); act.ParentStory = result; result.Acts.Add(act); } if (story[i].ReferTo("SEQUENCE")) { var sequence = ExtractSequenceFrom(story, ref i); sequence.ParentStory = result; result.Sequences.Add(sequence); } ExtractStoryDataFrom(ref story[i], ref result); } } return(result); }
public static RepeatStory Repeat(BaseStory story, int count) { return(new RepeatStory(story, count)); }