//剧情脚本模板加载回调 private void ScriptTemplateLoaded(TextAsset textObj) { if (null == textObj) { return; } string triggerName = "triggerTable>0>trigger"; XMLNode rootNode = XMLParser.Parse(textObj.ToString()); foreach (XMLNode triggerNode in rootNode.GetNodeList(triggerName)) { string scriptName = triggerNode.GetValue("@scriptName"); string type = triggerNode.GetValue("@type"); ScriptBaseEntry baseEntry = StoryFactory.GetEntry(type); if (null != baseEntry) { baseEntry.ScriptName = scriptName; baseEntry.ParseNode(triggerNode); scriptEntryList.Add(baseEntry); } } }
//剧情加载回调 private void ScriptLoaded(TextAsset textObj) { try { if (!scriptDict.ContainsKey(curScriptEntry.ScriptName)) { if (null != textObj) { scriptDict.Add(curScriptEntry.ScriptName, textObj); } } //判断文件是否存在 if (!scriptDict.ContainsKey(curScriptEntry.ScriptName)) { return; } if (null != AppMap.Instance.me.Controller.GoName) { roleGoActive = AppMap.Instance.me.Controller.GoName.activeSelf; } //解析剧情数据 string actionName = "script>0>action"; XMLNode rootNode = XMLParser.Parse(scriptDict[curScriptEntry.ScriptName].ToString()); if (null != rootNode) { foreach (XMLNode actionNode in rootNode.GetNodeList(actionName)) { string type = actionNode.GetValue("@type"); BaseAction baseAction = StoryFactory.GetAction(type); if (null != baseAction) { baseAction.ParseNode(actionNode); actionList.Add(baseAction); } } } } finally { loadingData = false; if (null != loadActionDataCallback) { loadActionDataCallback(); } } }
//播放玩家升级后剧情 public bool PlayLevelUpStory(ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptLevelUpEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_LEVEL_UP) as ScriptLevelUpEntry; result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放出场景剧情 public bool PlayExitSceneStory(uint mapId, ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptExitSceneEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_EXIT_SCENE) as ScriptExitSceneEntry; entry.SceneId = mapId.ToString(); result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放完成任务后剧情 public bool PlayFinishTaskStory(uint taskId, ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptFinishTaskEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_TASK_FINISHED) as ScriptFinishTaskEntry; entry.TaskId = taskId.ToString(); result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放主角走到某区域剧情 public bool PlayHeroArriveStory(uint mapId, Vector3 pos, ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptHeroArriveAreaEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HERO_ARRIVE_AREA) as ScriptHeroArriveAreaEntry; entry.SceneId = mapId.ToString(); entry.Position = pos; result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放怪物HP更改剧情 public bool PlayMonsterHpChangeStory(string monsterId, ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptHpChangeEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HP_CHANGE) as ScriptHpChangeEntry; entry.RoleType = StoryConst.MONSTER; entry.Id = monsterId; result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放主角HP更改剧情 public bool PlayHeroHpChangeStory(ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptHpChangeEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_HP_CHANGE) as ScriptHpChangeEntry; entry.RoleType = string.Empty; entry.Id = StoryConst.SELF_ID; result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }
//播放阶段战斗剧情 public bool PlayFightStageStory(uint mapId, uint stageId, uint monsterId, ClosedCallback callBack) { bool result = false; closedCallback = callBack; ScriptFightStageEntry entry = StoryFactory.GetEntry(StoryConst.TRIG_FIGHT_STAGE) as ScriptFightStageEntry; entry.SceneId = mapId.ToString(); entry.StageId = stageId.ToString(); entry.MonsterId = monsterId.ToString(); result = Singleton <StoryMode> .Instance.StoryExits(entry); if (result) { Singleton <StoryMode> .Instance.LoadActionData(entry, LoadDataCallback); } return(result); }