private StoryInstanceInfo NewStoryInstance(int storyId) { StoryInstanceInfo instInfo = GetUnusedStoryInstanceInfoFromPool(storyId); if (null == instInfo) { StoryInstance inst = m_ConfigManager.NewStoryInstance(storyId, 0); if (inst == null) { LogSystem.Error("Can't load story config, story:{0} !", storyId); return(null); } StoryInstanceInfo res = new StoryInstanceInfo(); res.m_StoryId = storyId; res.m_StoryInstance = inst; res.m_IsUsed = true; AddStoryInstanceInfoToPool(storyId, res); return(res); } else { instInfo.m_IsUsed = true; return(instInfo); } }
internal void PreloadStoryInstance(int storyId) { StoryInstanceInfo info = NewStoryInstance(storyId, false); if (null != info) { RecycleStorylInstance(info); } }
internal void SendMessage(string msgId, params object[] args) { int ct = m_StoryLogicInfos.Count; for (int ix = ct - 1; ix >= 0; --ix) { StoryInstanceInfo info = m_StoryLogicInfos[ix]; info.m_StoryInstance.SendMessage(msgId, args); } }
public void SendMessage(string MsgId, params object[] args) { int num = m_listStoryLogicInfos.Count; for (int index = num - 1; index >= 0; index++) { StoryInstanceInfo info = m_listStoryLogicInfos[index]; info.m_oInstance.SendMessage(MsgId, args); } }
internal void StopAllStories() { int count = m_StoryLogicInfos.Count; for (int index = count - 1; index >= 0; --index) { StoryInstanceInfo info = m_StoryLogicInfos[index]; RecycleStorylInstance(info); m_StoryLogicInfos.RemoveAt(index); } }
/// <summary> /// 开始剧情 /// </summary> /// <param name="storyId"></param> public void StartStory(int storyId) { StoryInstanceInfo instance = NewStoryInstance(storyId); if (instance != null) { m_listStoryLogicInfos.Add(instance); instance.m_oInstance.GlobalVariables = m_dicGlobalVariables; instance.m_oInstance.Start(); } }
private void AddStoryInstanceInfoToPool(int storyId, StoryInstanceInfo info) { if (m_dicStoryInstancePool.ContainsKey(storyId)) { List <StoryInstanceInfo> list = m_dicStoryInstancePool[storyId]; list.Add(info); } else { List <StoryInstanceInfo> list1 = new List <StoryInstanceInfo>(); list1.Add(info); m_dicStoryInstancePool.Add(storyId, list1); } }
/// <summary> /// 停止剧情 /// </summary> /// <param name="storyId"></param> public void StopStory(int storyId) { int count = m_listStoryLogicInfos.Count; for (int index = count - 1; index >= 0; index--) { StoryInstanceInfo info = m_listStoryLogicInfos[index]; if (info.m_iStoryId == storyId) { RecycleStoryInstanceInfo(info); m_listStoryLogicInfos.RemoveAt(index); } } }
private void AddStoryInstanceInfoToPool(int storyId, StoryInstanceInfo info) { if (m_StoryInstancePool.ContainsKey(storyId)) { List <StoryInstanceInfo> infos = m_StoryInstancePool[storyId]; infos.Add(info); } else { List <StoryInstanceInfo> infos = new List <StoryInstanceInfo>(); infos.Add(info); m_StoryInstancePool.Add(storyId, infos); } }
internal void StartStory(int storyId) { StoryInstanceInfo inst = NewStoryInstance(storyId); if (null != inst) { m_StoryLogicInfos.Add(inst); inst.m_StoryInstance.Context = m_CurScene; inst.m_StoryInstance.GlobalVariables = m_GlobalVariables; inst.m_StoryInstance.Start(); LogSystem.Info("StartStory {0}", storyId); } }
internal void StopStory(int storyId) { int count = m_StoryLogicInfos.Count; for (int index = count - 1; index >= 0; --index) { StoryInstanceInfo info = m_StoryLogicInfos[index]; if (info.m_StoryId == storyId) { RecycleStorylInstance(info); m_StoryLogicInfos.RemoveAt(index); } } }
private StoryInstanceInfo NewStoryInstance(int storyId, bool logIfNotFound) { StoryInstanceInfo instInfo = GetUnusedStoryInstanceInfoFromPool(storyId); if (null == instInfo) { int sceneResId = m_CurScene.SceneResId; Data_SceneConfig cfg = SceneConfigProvider.Instance.GetSceneConfigById(sceneResId); if (null != cfg) { int ct = cfg.m_StoryDslFile.Count; string[] filePath = new string[ct]; for (int i = 0; i < ct; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_RootPath + cfg.m_StoryDslFile[i]); } StoryConfigManager.Instance.LoadStoryIfNotExist(storyId, sceneResId, filePath); StoryInstance inst = StoryConfigManager.Instance.NewStoryInstance(storyId, sceneResId); if (inst == null) { if (logIfNotFound) { LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, sceneResId); } return(null); } StoryInstanceInfo res = new StoryInstanceInfo(); res.m_StoryId = storyId; res.m_StoryInstance = inst; res.m_IsUsed = true; AddStoryInstanceInfoToPool(storyId, res); return(res); } else { if (logIfNotFound) { LogSystem.Error("Can't find story config, story:{0} scene:{1} !", storyId, sceneResId); } return(null); } } else { instInfo.m_IsUsed = true; return(instInfo); } }
private void AddStoryInstanceInfoToPool(int storyId, StoryInstanceInfo info) { List <StoryInstanceInfo> infos; if (m_StoryInstancePool.TryGetValue(storyId, out infos)) { infos.Add(info); } else { infos = new List <StoryInstanceInfo>(); infos.Add(info); m_StoryInstancePool.Add(storyId, infos); } }
internal void Tick() { long time = TimeUtility.GetLocalMilliseconds(); int ct = m_StoryLogicInfos.Count; for (int ix = ct - 1; ix >= 0; --ix) { StoryInstanceInfo info = m_StoryLogicInfos[ix]; info.m_StoryInstance.Tick(time); if (info.m_StoryInstance.IsTerminated) { RecycleStorylInstance(info); m_StoryLogicInfos.RemoveAt(ix); } } }
public void Tick() { long time = UnityTools.GetLocalMilliseconds(); int num = m_listStoryLogicInfos.Count; for (int index = num - 1; index >= 0; index--) { StoryInstanceInfo info = m_listStoryLogicInfos[index]; info.m_oInstance.Tick(time); if (info.m_oInstance.IsTerminated) { RecycleStoryInstanceInfo(info); m_listStoryLogicInfos.RemoveAt(index); } } }
internal void Reset() { m_GlobalVariables.Clear(); int count = m_StoryLogicInfos.Count; for (int index = count - 1; index >= 0; --index) { StoryInstanceInfo info = m_StoryLogicInfos[index]; if (null != info) { RecycleStorylInstance(info); m_StoryLogicInfos.RemoveAt(index); } } m_StoryLogicInfos.Clear(); }
public void Tick() { long time = DateTime.Now.Ticks / 10 - this.m_fStartTime; int num = m_listStoryLogicInfos.Count; for (int index = num - 1; index >= 0; index--) { StoryInstanceInfo info = m_listStoryLogicInfos[index]; info.m_oInstance.Tick(time); if (info.m_oInstance.IsTerminated) { RecycleStoryInstanceInfo(info); m_listStoryLogicInfos.RemoveAt(index); } } }
private StoryInstanceInfo NewStoryInstance(int storyId) { //去剧情缓冲池里面找实例 StoryInstanceInfo instInfo = GetUnusedStoryInstanceInfoFromPool(storyId); if (instInfo == null) { //这里应该是现在角色所在的场景id DataSceneConfig cfg = GameData <DataSceneConfig> .dataMap[storyId]; if (cfg != null) { string[] filePath = new string[1] { cfg.StoryDSLFile }; for (int i = 0; i < 1; i++) { filePath[i] = Application.dataPath + "/Resources/" + cfg.StoryDSLFile; } StoryConfigManager.Instance.LoadStoryIfNotExist(storyId, 0, filePath); StoryInstance inst = StoryConfigManager.Instance.NewStoryInstance(storyId, 0); if (inst == null) { Debug.LogError("不能加载剧情:" + storyId); return(null); } StoryInstanceInfo info = new StoryInstanceInfo(); info.m_iStoryId = storyId; info.m_oInstance = inst; info.m_bIsUsed = true; AddStoryInstanceInfoToPool(storyId, info); return(info); } else { Debug.LogError("不能找到剧情" + storyId + "配置文件"); return(null); } } else { instInfo.m_bIsUsed = true; return(instInfo); } }
private StoryInstanceInfo GetUnusedStoryInstanceInfoFromPool(int storyId) { StoryInstanceInfo info = null; if (m_dicStoryInstancePool.ContainsKey(storyId)) { var infos = m_dicStoryInstancePool[storyId]; foreach (var inst in infos) { if (!inst.m_bIsUsed) { info = inst; break; } } } return(info); }
private StoryInstanceInfo GetUnusedStoryInstanceInfoFromPool(int storyId) { StoryInstanceInfo info = null; List <StoryInstanceInfo> infos; if (m_StoryInstancePool.TryGetValue(storyId, out infos)) { int ct = infos.Count; for (int ix = 0; ix < ct; ++ix) { if (!infos[ix].m_IsUsed) { info = infos[ix]; break; } } } return(info); }
private StoryInstanceInfo GetUnusedStoryInstanceInfoFromPool(int storyId) { StoryInstanceInfo info = null; if (m_StoryInstancePool.ContainsKey(storyId)) { List <StoryInstanceInfo> infos = m_StoryInstancePool[storyId]; int ct = infos.Count; for (int ix = 0; ix < ct; ++ix) { if (!infos[ix].m_IsUsed) { info = infos[ix]; break; } } } return(info); }
private void RecycleStorylInstance(StoryInstanceInfo info) { info.m_StoryInstance.Reset(); info.m_IsUsed = false; }
private void RecycleStoryInstanceInfo(StoryInstanceInfo info) { info.m_oInstance.Reset(); info.m_bIsUsed = false; }