/// <summary> /// 读取工程 /// </summary> /// <param name="projFile">工程文件</param> public void LoadProject(string projFile) { FileInfo fileinf = new FileInfo(projFile); Halation.projectFolder = fileinf.DirectoryName; Halation.project = (ProjectPackage)FileManager.Unserialization(projFile); Halation.project.Config = new ConfigPackage(); var lconfig = FileManager.LoadConfigData(Halation.projectFolder + "\\YuriConfig.dat"); foreach (var configKVP in lconfig) { Halation.SetValueByName <ConfigPackage>(Halation.project.Config, configKVP.Item1, configKVP.Item2, configKVP.Item3); } Halation.projectName = Halation.project.Config.GameProjName; foreach (var sc in Halation.project.GetScene()) { HalationInvoker.AddScene(sc.sceneName); foreach (var fc in sc.GetFunc()) { HalationInvoker.AddScene(fc.functionCallName); } } this.RefreshProjectTree("main"); }
/// <summary> /// 进行代码编译 /// </summary> public void DashParse() { // 保存全局配置 FileManager.SaveConfigData(Halation.projectFolder + "\\YuriConfig.dat", Halation.GetNameAndValue <ConfigPackage>(Halation.project.Config)); // 翻译可视化事件到脚本 var scripts = CodeGenerator.GetInstance().Generate(); FileManager.SaveByLineItem(Halation.projectFolder + "\\" + FileManager.DevURI_RT_SCENARIO, ".sls", scripts); // 编译 try { Interpreter ip = new Interpreter(Halation.projectName, Halation.projectFolder + "\\" + FileManager.DevURI_RT_SCENARIO, Halation.project.Config.GameProjKey); ip.Dash(InterpreterType.RELEASE_WITH_IL, 4); ip.GenerateIL(Halation.projectFolder + "\\" + FileManager.DevURI_RT_SCENARIO + @"\main.sil"); } catch (Exception ex) { MessageBox.Show("编译失败" + Environment.NewLine + ex); throw ex; } }
/// <summary> /// 遍历一个类的所有值字段 /// </summary> /// <typeparam name="T">要遍历的类型</typeparam> /// <param name="t">类型的实例</param> /// <returns>一个包含了字段与字段值键值对的向量</returns> public static List <Tuple <string, object, int> > GetNameAndValue <T>(T t) { var resList = new List <Tuple <string, object, int> >(); if (t == null) { return(resList); } var properties = t.GetType().GetFields(); if (properties.Length <= 0) { return(resList); } resList.AddRange(properties.Select(item => new Tuple <string, object, int>(item.Name, item.GetValue(t), Halation.MapTypeToNum(item.FieldType)))); return(resList); }