private static bool CheckGroup(GameConfigGroups groups) { if (groups == null) { Debug.LogError("config data is null!"); return(false); } return(true); }
private static void GetAllFileByXmlLevelGroup(GameConfigGroups groups) { if (!CheckGroup(groups)) { return; } GameXmlGroup[] gameXmlGroups = groups.gameXmlGroups; //获取序列化xmlgroups所需要的数据; if (gameXmlGroups != null && gameXmlGroups.Length > 0) { XmlGroupSettings tempXmlGroups = null; //detail config mXmlLevelGroups.Clear(); for (int i = 0; i < gameXmlGroups.Length; i++) { tempXmlGroups = new XmlGroupSettings(); List <GameXmlFile> t_files = new List <GameXmlFile> (gameXmlGroups[i].gameXmlFiles); for (int j = 0; j < t_files.Count; j++) { string t_name = Path.GetFileNameWithoutExtension(t_files[j].Path); if (string.IsNullOrEmpty(t_name)) { GameXmlFile temp = t_files [j]; t_files.Remove(temp); string dirPath = string.Format("{0}/../conf/{1}", Application.dataPath, temp.Path); if (!Directory.Exists(dirPath)) { Debug.LogError("dir is not exists : " + dirPath); continue; } string[] allPath = Directory.GetFiles(dirPath, "*.xml", SearchOption.AllDirectories); for (int t = 0; t < allPath.Length; t++) { GameXmlFile xFile = new GameXmlFile(); xFile.Path = allPath[t].Replace('\\', '/'); string t_Path = string.Format("{0}/../conf/", Application.dataPath); xFile.Path = xFile.Path.Replace(t_Path, ""); xFile.TypeName = temp.TypeName; t_files.Insert(j, xFile); } } } GameXmlFile[] files = t_files.ToArray(); tempXmlGroups.group = string.Format("{0}/../conf/{1}", Application.dataPath, gameXmlGroups[i].Group); if (files == null) { Debug.LogError("xmlgroup config error!"); return; } tempXmlGroups.xmlFiles = new XmlGroupSettings.XmlData[files.Length]; for (int j = 0; j < files.Length; j++) { tempXmlGroups.xmlFiles[j] = new XmlGroupSettings.XmlData(); tempXmlGroups.xmlFiles[j].path = string.Format("{0}/../conf/{1}", Application.dataPath, files[j].Path.Replace('\\', '/')); tempXmlGroups.xmlFiles[j].typeName = files[j].TypeName; } mXmlLevelGroups.Add(tempXmlGroups); tempXmlGroups = null; } } }
private static void GetAllFileBySheetGroup(GameConfigGroups groups) { if (!CheckGroup(groups)) { return; } GameXmlSheetGroup[] gameXmlSheetGroups = groups.gameXmlSheetGroups; //获取序列化xmlsheetgroups所需要的数据; if (gameXmlSheetGroups != null && gameXmlSheetGroups.Length > 0) { XmlSheetGroupSettings tempGroups = null; //detail config List <XmlSheetGroupSettings.XmlSheetFile> mXmlSheetFileList = new List <XmlSheetGroupSettings.XmlSheetFile>(); mXmlSheetGroups.Clear(); for (int i = 0; i < gameXmlSheetGroups.Length; i++) { tempGroups = new XmlSheetGroupSettings(); GameXmlSheet[] sheet = gameXmlSheetGroups[i].gameSheets; tempGroups.group = string.Format("{0}/../conf/{1}", Application.dataPath, gameXmlSheetGroups[i].Group); if (sheet == null) { Debug.LogError("xmlsheetgroups config error!"); return; } tempGroups.sheetFiles = new XmlSheetGroupSettings.XmlSheetData[sheet.Length]; for (int k = 0; k < sheet.Length; k++) { tempGroups.sheetFiles[k] = new XmlSheetGroupSettings.XmlSheetData(); tempGroups.sheetFiles[k].sheetName = sheet[k].SheetName; mXmlSheetFileList.Clear(); if (sheet[k].gameXmlSheetFile == null) { continue; } for (int j = 0; j < sheet[k].gameXmlSheetFile.Length; j++) { string dirPath = string.Format("{0}/../conf/{1}", Application.dataPath, sheet[k].gameXmlSheetFile[j].Dir); if (!Directory.Exists(dirPath)) { Debug.LogError("dir is not exists : " + dirPath); continue; } string[] allPath = Directory.GetFiles(dirPath, "*.xml", SearchOption.AllDirectories); for (int t = 0; t < allPath.Length; t++) { XmlSheetGroupSettings.XmlSheetFile xFile = new XmlSheetGroupSettings.XmlSheetFile(); xFile.filePath = allPath[t].Replace('\\', '/'); xFile.typeName = sheet[k].gameXmlSheetFile[j].TypeName; mXmlSheetFileList.Add(xFile); } } tempGroups.sheetFiles[k].files = mXmlSheetFileList.ToArray(); mXmlSheetFileList.Clear(); } mXmlSheetGroups.Add(tempGroups); tempGroups = null; } } }