override public bool OnFetchData(DataTable dataTable, int rowCount) { string fullPath = string.Format("{0}/{1}/{2}.cs", Application.dataPath, script.targetPath, script.tableName); string header = CSharpSentence.USING_Layout(CSharpSentence.USING_UnityEngine) + CSharpSentence.USING_Layout(CSharpSentence.USING_Collections); string layout = ""; string className = "DataFormula"; string method = ""; if (rowCount > 0) { layout = header; for (int i = 0; i < rowCount; i++) { string ID = dataTable.Rows[i][dataTable.Columns["ID"]].ToString(); string Formula = dataTable.Rows[i][dataTable.Columns["Formula"]].ToString(); string Result = dataTable.Rows[i][dataTable.Columns["Result"]].ToString(); method += CSharpSentence.METHOD_RESULT_Layout("static", className, "Formula_" + ID, Result + " = " + Formula); } layout += CSharpSentence.CLASS_Layout(script.tableName, method); layout = string.Format("{0}\n\ndelegate {1} DelegateFormula ({1} result, {1} owner, params {1}[] other);", layout, className); ComSystemIO.Create(fullPath, layout); string fullPath1 = string.Format("{0}/{1}/FormulaMgr_SetBase.cs", Application.dataPath, script.targetPath); string data1 = string.Format("using UnityEngine;\nusing System.Collections;\n\npublic partial class FormulaMgr\n{0}", "{"); data1 = string.Format( "{0}\n" + "\tpublic void Init ()\n" + "\t{1}", data1, "{"); for (int i = 0; i < rowCount; i++) { string ID = dataTable.Rows[i][dataTable.Columns["ID"]].ToString(); data1 = string.Format( "{0}\n" + "\t\tbaseFormulaDic.Add({1}, {2}.Formula_{1});" , data1, ID, script.tableName); } data1 = string.Format("{0}\n\t{1}", data1, "}"); data1 = string.Format("{0}\n{1}", data1, "}"); ComSystemIO.Create(fullPath1, data1); } return(true); }
override public bool OnFetchData(DataTable dataTable, int rowCount) { string[] ColumnArray = new string[dataTable.Columns.Count - 1]; string fullPath = string.Format("{0}/{1}/{2}.cs", Application.dataPath, script.targetPath, script.tableName); string data = string.Format("using UnityEngine;\nusing System.Collections;\nusing System;\n\n[Serializable]\npublic class {0}\n{1}", script.tableName, "{"); for (int i = 1; i < dataTable.Columns.Count; i++) { if (string.IsNullOrEmpty(dataTable.Columns[i].ColumnName)) { continue; } data = string.Format("{0}\n\tpublic {1}\t{2}\t{3}", data, dataTable.Rows[0][dataTable.Columns[i].ColumnName].ToString(), dataTable.Columns[i].ColumnName, ";"); ColumnArray[i - 1] = dataTable.Columns[i].ColumnName; } data = string.Format("{0}\n\n\tpublic {1} ({1} orgData)\n\t{2}\n", data, script.tableName, "{"); for (int i = 0; i < ColumnArray.Length; i++) { data = string.Format("{0}\t\t{1} = orgData.{1} ;\n", data, ColumnArray[i]); } data = string.Format("{0}\t{1}", data, "}"); data = string.Format("{0}\n{1}", data, "}"); // Debug.Log (AssetDatabase.AssetPathToGUID (string.Format ("Assets/{0}/{1}.cs", script.targetPath, script.tableName))); ComSystemIO.Create(fullPath, data); // Debug.Log (AssetDatabase.AssetPathToGUID (string.Format ("Assets/{0}/{1}.cs", script.targetPath, script.tableName))); return(true); }