// static List<string> EmurateFilesUnderPath(string basePath, string extension) // { // List<string> files = new List<string>(); // foreach(string file in System.IO.Directory.GetFiles(basePath)) // { // var ext = Path.GetExtension(file); // if (extension.Length == 0 || extension == ext) // { // files.Add(file.Replace(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar)); // } // } // foreach(string dir in System.IO.Directory.GetDirectories(basePath)) // { // files.AddRange(EmurateFilesUnderPath(dir, extension)); // } // return files; // } // 场景CSV文件加载回调aa static void OnCSVLoad(string key, SDCSV csv) { string kCurrentScene = EditorApplication.currentScene; foreach (DictionaryEntry de in csv.csvTable) { string id = de.Key.ToString(); Hashtable table = de.Value as Hashtable; string levelPath = table["Scene"] as string; string strLevelPath = "Assets/" + levelPath + ".unity"; if (EditorApplication.OpenScene(strLevelPath)) { Debug.LogWarning("exporting scene " + strLevelPath); if (!CreateMonsterXmlByLevelID(id)) { Debug.LogError("failed to create monster xml of scene " + strLevelPath); } } else { Debug.LogError("failed to open scene " + strLevelPath); } } EditorApplication.OpenScene(kCurrentScene); }
public static void LoadLevelConfig(string level, string levelLang, string levelMeta, string levelBox) { SDCSV levelCSV = new SDCSV(); SDCSV levelLangCSV = new SDCSV(); SDCSV levelMetaCSV = new SDCSV(); SDCSV levelBoxCSV = new SDCSV(); levelCSV.CreateCSVFromStr(level, 0); levelLangCSV.CreateCSVFromStr(levelLang, 0); levelMetaCSV.CreateCSVFromStr(levelMeta, 1); levelBoxCSV.CreateCSVFromStr(levelBox, 0); //首先遍历level表的每一行,每一行又是一个HashTable... levelInfos = new LevelItem[levelCSV.csvTable.Count]; int count = 0; foreach (DictionaryEntry de in levelCSV.csvTable) { levelInfos[count] = new LevelItem(); string key = (string)de.Key; Hashtable valTable = (Hashtable)de.Value; levelInfos[count].levelID = int.Parse(key); //然后遍历行中的每一列,每一列是一个string foreach (DictionaryEntry de2 in valTable) { //获得名字.. string name = (string)de2.Key; string val = (string)de2.Value; //通过名字查找metaTable,获得数据类型.. Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name]; string type = (string)meta["Type"]; if (type == "int") { levelInfos[count].levelProp.Add(name, int.Parse(val)); } else { levelInfos[count].levelProp.Add(name, val); } } //读取国际化表对应的行.. Hashtable langHash = (Hashtable)levelLangCSV.csvTable[key]; if (langHash != null) { foreach (DictionaryEntry de3 in langHash) { //获得名字.. string name = (string)de3.Key; string val = (string)de3.Value; //通过名字查找metaTable,获得数据类型.. Hashtable meta = (Hashtable)levelMetaCSV.csvTable[name]; string type = (string)meta["Type"]; if (type == "int") { levelInfos[count].levelProp[name] = int.Parse(val); } else { levelInfos[count].levelProp[name] = val; } } } count++; } for (count = 1; count <= 16; count++) { battleInfos[count] = new BattleItem(); } // 处理关卡领奖数据结构. foreach (DictionaryEntry de in levelBoxCSV.csvTable) { string key = (string)de.Key; Hashtable valTable = (Hashtable)de.Value; uint bid = 0; BattleBoxItem box = new BattleBoxItem(); box.BoxID = uint.Parse(key); foreach (DictionaryEntry de2 in valTable) { string name = (string)de2.Key; string val = (string)de2.Value; if (name == "BattleID") { bid = uint.Parse(val); } else if (name == "Job") { box.Job = uint.Parse(val); } else if (name == "NeedStar") { box.NeedStar = uint.Parse(val); } else if (name == "NonMoney") { box.NonMoney = uint.Parse(val); } else if (name == "NonCash") { box.NonCash = uint.Parse(val); } else if (name == "i1.TID") { box.Item1ID = uint.Parse(val); } else if (name == "i1.Count") { box.Item1Count = uint.Parse(val); } else if (name == "i2.TID") { box.Item2ID = uint.Parse(val); } else if (name == "i2.Count") { box.Item2Count = uint.Parse(val); } else if (name == "i3.TID") { box.Item3ID = uint.Parse(val); } else if (name == "i3.Count") { box.Item3Count = uint.Parse(val); } } // 总计16个战役,从1开始. if (bid >= 1 && bid <= 16) { if (box.NeedStar <= 18) { count = 0; } else if (box.NeedStar <= 36) { count = 1; } else { count = 2; } int job = 0; if (box.Job == 1) { job = 1; // 战士. } else if (box.Job == 4) { job = 2; // 法师. } else if (box.Job == 7) { job = 3; // 游侠. } else if (box.Job == 10) { job = 4; // 牧师. } //battleInfos[bid].rewardBox[count,job] = new BattleBoxItem(); battleInfos[bid].rewardBox[count, job] = box; } } }
static void CreateMonsterXmlAllTuituLevel() { SDCSV kCSV = new SDCSV(); kCSV.LoadCSVInTestMode("$Conf/level.txt", OnCSVLoad); }