示例#1
0
 private void Init()
 {
     if (Setting == null)
     {
         Setting = BattleEditorUtility.LoadSetting(SettingPath);
     }
 }
示例#2
0
 public void Reload()
 {
     _excelReader?.Dispose();
     _excelReader = new ExcelReader();
     _excelReader.LoadExcelFile(Application.dataPath + _excelPath);
     _excelColHeaderDict = BattleEditorUtility.GetExcelHeaderList(_excelPath);
     _dataTable          = _excelReader.dataTable;
 }
示例#3
0
        private void OnGUI()
        {
            EditorGUILayout.Space();
            if (_luaReflect == null)
            {
                List <string> excelFileList = BattleEditorUtility.GetExcelFileList(Setting.excelFolder);
                for (int i = 0; i < excelFileList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(excelFileList[i]);
                    if (NeedGenerateHeaderJson(excelFileList[i]) && GUILayout.Button("Generate"))
                    {
                        ExcelEditor excelEditor = new ExcelEditor(excelFileList[i]);
                        excelEditor.GenerateHeaderJson(false);
                    }
                    if (GUILayout.Button("Force Generate"))
                    {
                        ExcelEditor excelEditor = new ExcelEditor(excelFileList[i]);
                        excelEditor.GenerateHeaderJson(true);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("请先启动游戏,并进入测试关卡", MessageType.Warning);
            }
            else
            {
                if (_luaReflectDict != null)
                {
                    EditorGUILayout.BeginHorizontal();
//                    foreach (var camp in Camp)
                    {
                        var camp = _camp[0];
                        EditorGUILayout.BeginVertical();
                        EditorGUILayout.LabelField(camp);
                        if (_luaReflectDict.TryGetValue(camp, out List <LuaReflect> list))
                        {
                            for (int i = 0; i < list.Count; i++)
                            {
                                LuaReflect luaReflect = list[i];
                                if (luaReflect)
                                {
                                    DrawLuaReflect(list, camp, luaReflect);
                                }
                            }
                        }
                        EditorGUILayout.EndVertical();
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (GUILayout.Button("Add Attacker" + _camp[0]))
                {
                    SelectWnd wnd = SelectWnd.Create("Select Attacker", this, _luaReflect, Setting.battleUnitExcelPath);
                    wnd.rowSelect = delegate(string battleUnit, int index) { AddBattle(battleUnit); };
                }
            }
        }
示例#4
0
        static void DoExcelToLua(bool isForce)
        {
            setting = BattleEditorUtility.LoadSetting(SettingPath);
            string        md5Path       = Application.dataPath + setting.excelFolder + "md5.txt";
            List <string> excelFileList = BattleEditorUtility.GetExcelFileList(setting.excelFolder);

            md5Dict = BattleEditorUtility.GetDictionaryFromFile(md5Path);
            if (md5Dict == null)
            {
                md5Dict = new Dictionary <string, string>();
            }
            Debug.Log("<color=#3A9BF8FF>Begin Export</color><color=#FFFFFFFF>:</color>");
            for (int i = 0; i < excelFileList.Count; i++)
            {
                var excelFilePath = excelFileList[i];
                var excelFileName = Path.GetFileName(excelFilePath);
                var md5           = BattleEditorUtility.GetFileMD5(excelFilePath.Replace("/../", ""));
                md5Dict.TryGetValue(excelFileName, out string oldMd5);
                bool modify = true;
                if (string.IsNullOrEmpty(oldMd5))
                {
                    md5Dict.Add(excelFileName, md5);
                }
                else if (oldMd5 != md5)
                {
                    md5Dict[excelFileName] = md5;
                }
                else
                {
                    modify = false;
                }
                if (isForce || modify)
                {
                    Debug.Log($"<color=#3A9BF8FF>Export Lua Table - </color><color=#FFFFFFFF>{excelFileName}</color>");
                    ExcelEditor excelEditor = new ExcelEditor(excelFilePath);
                    excelEditor.Reload();
                    var outputPath = $"{setting.outputPath}/{Path.GetFileNameWithoutExtension(excelFilePath)}.lua";
                    GenerateLua(excelEditor.excelReader, outputPath);
                    BattleEditorUtility.DisplayProgress(i, excelFileList.Count, excelFilePath);
                }
            }
            Debug.Log("<color=#3A9BF8FF>End Export</color><color=#FFFFFFFF>:</color>");
            BattleEditorUtility.SaveDictionary(md5Path, md5Dict);
            EditorUtility.ClearProgressBar();
        }
示例#5
0
 public ExcelColHeader(string fieldName, JsonData json)
 {
     this.fieldName = fieldName;
     if (json.Keys.Contains("fieldType"))
     {
         fieldType = json["fieldType"].ToString();
     }
     if (json.Keys.Contains("editorType"))
     {
         editorType = json["editorType"].ToString();
     }
     if (json.Keys.Contains("minFloatValue"))
     {
         minFloatValue = float.Parse(json["minFloatValue"].ToString());
     }
     if (json.Keys.Contains("maxFloatValue"))
     {
         maxFloatValue = float.Parse(json["maxFloatValue"].ToString());
     }
     if (json.Keys.Contains("minIntValue"))
     {
         minIntValue = int.Parse(json["minIntValue"].ToString());
     }
     if (json.Keys.Contains("maxIntValue"))
     {
         maxIntValue = int.Parse(json["maxIntValue"].ToString());
     }
     if (json.Keys.Contains("fieldEnum"))
     {
         fieldEnum = BattleEditorUtility.JsonToArray(json, "fieldEnum");
     }
     if (json.Keys.Contains("linkEditorUrl"))
     {
         linkEditorUrl = json["linkEditorUrl"].ToString();
     }
     if (json.Keys.Contains("linkEditorField"))
     {
         linkEditorField = json["linkEditorField"].ToString();
     }
     if (json.Keys.Contains("linkEditorLuaKey"))
     {
         linkEditorLuaKey = json["linkEditorLuaKey"].ToString();
     }
 }
示例#6
0
        public void GenerateHeaderJson(bool forceGenerate)
        {
            var jsonPath = Application.dataPath + _excelPath.Replace(".xlsx", ".json");

            if (forceGenerate && File.Exists(jsonPath))
            {
                File.Delete(jsonPath);
            }
            if (!File.Exists(jsonPath))
            {
                JsonData json = new JsonData();
                for (int i = 0; i < _dataTable.Columns.Count; i++)
                {
                    var      fieldName  = _dataTable.Columns[i].ToString();
                    var      fieldType  = _dataTable.Rows[0][i].ToString();
                    JsonData headerNode = new JsonData();
                    json[fieldName]         = headerNode;
                    headerNode["fieldType"] = fieldType;
                }
                string jsonStr = JsonMapper.ToJson(json);
                BattleEditorUtility.SaveUTF8TextFile(jsonPath, JCode.ToFormart(jsonStr));
            }
        }
示例#7
0
        public string GetRowJson(int rowIndex)
        {
            var json = BattleEditorUtility.DataRowToJson(_excelReader.dataTable.Columns, _excelReader.dataTable.Rows[rowIndex + 2]);

            return(json);
        }