static Dictionary <string, List <string> > FindVisitStoryAudio() { DirectoryInfo dir = new DirectoryInfo(Application.persistentDataPath + "/DataCache/visiting_c"); if (dir.Exists == false) { Debug.LogError("visiting_c文件夹不存在!"); return(null); } FileInfo[] files = dir.GetFiles("*"); FileInfo targetFile = null; foreach (FileInfo file in files) { if (file.Name.ToLower().StartsWith("rules")) { targetFile = file; break; } } if (targetFile == null) { Debug.LogError("visiting_c/rules文件不存在!"); return(null); } Dictionary <string, List <string> > fileDict = new Dictionary <string, List <string> >(); EditorUtility.DisplayProgressBar("查找VisitStory音频", "", 0); byte[] dataFile = FileUtil.GetBytesFile(targetFile.DirectoryName, targetFile.Name); MemoryStream m = new MemoryStream(dataFile); MessageParser <VisitingRuleRes> parser = new MessageParser <VisitingRuleRes>(() => new VisitingRuleRes()); VisitingRuleRes res = parser.ParseFrom(m); int count = 0; foreach (var rule in res.LevelRules) { count++; if (rule.Type == LevelTypePB.Story) { string playerId = ((int)rule.Player) + ""; if (fileDict.ContainsKey(playerId) == false) { fileDict.Add(playerId, new List <string>()); } fileDict[playerId].AddRange(GetStoryAudio(rule.LevelMark)); EditorUtility.DisplayProgressBar("查找VisitStory音频", "playerId:" + playerId + "(" + count + ")", 1); } } string str = JsonConvert.SerializeObject(fileDict, Formatting.Indented); FileUtil.SaveFileText(GetPackageDir(), "VisitStoryAudio.json", str); EditorUtility.ClearProgressBar(); return(fileDict); }
static Dictionary <string, List <string> > FindLoveStoryAudio() { DirectoryInfo dir = new DirectoryInfo(Application.persistentDataPath + "/DataCache/appointment_c"); if (dir.Exists == false) { Debug.LogError("appointment_c文件夹不存在!"); return(null); } FileInfo[] files = dir.GetFiles("*"); FileInfo targetFile = null; foreach (FileInfo file in files) { if (file.Name.ToLower().StartsWith("rules")) { targetFile = file; break; } } if (targetFile == null) { Debug.LogError("appointment_c/rules文件不存在!"); return(null); } Dictionary <string, List <string> > fileDict = new Dictionary <string, List <string> >(); EditorUtility.DisplayProgressBar("查找LoveStory音频", "", 0); byte[] dataFile = FileUtil.GetBytesFile(targetFile.DirectoryName, targetFile.Name); MemoryStream m = new MemoryStream(dataFile); MessageParser <AppointmentRuleRes> parser = new MessageParser <AppointmentRuleRes>(() => new AppointmentRuleRes()); AppointmentRuleRes res = parser.ParseFrom(m); int count = 0; foreach (var rule in res.AppointmentRules) { count++; string cardId = rule.ActiveCards[0].ToString(); fileDict.Add(cardId, new List <string>()); foreach (var pb in rule.GateInfos) { fileDict[cardId].AddRange(GetStoryAudio(pb.SceneId)); } EditorUtility.DisplayProgressBar("查找LoveStory音频", "cardId:" + cardId + "(" + count + "/" + res.AppointmentRules.Count + ")", (float)count / res.AppointmentRules.Count); } string str = JsonConvert.SerializeObject(fileDict, Formatting.Indented); FileUtil.SaveFileText(GetPackageDir(), "LoveStoryAudio.json", str); EditorUtility.ClearProgressBar(); return(fileDict); }