/// <summary> /// 法术的导入 /// </summary> /// <param name="target"></param> /// <param name="workbook"></param> private void Ability(dynamic workbook) { if (Directory.Exists(ExportFolderPicker.SelectedPathOrFileName + "\\Ability\\")) { Directory.Delete(ExportFolderPicker.SelectedPathOrFileName + "\\Ability\\", true); } Directory.CreateDirectory(ExportFolderPicker.SelectedPathOrFileName + "\\Ability\\"); //法术的导入 dynamic worksheet = workbook.Sheets(2); int rowCount = 4; SpellCard Ability; while (!string.IsNullOrEmpty(worksheet.Cells(rowCount, 2).Text)) { //当前行肯定是卡牌基本情报 Ability = new SpellCard(); Ability.序列号 = worksheet.Cells(rowCount, 2).Text; Ability.名称 = worksheet.Cells(rowCount, 3).Text; Ability.描述 = worksheet.Cells(rowCount, 4).Text; Ability.职业 = CSharpUtility.GetEnum<CardUtility.职业枚举>(worksheet.Cells(rowCount, 9).Text, CardUtility.职业枚举.中立); Ability.使用成本 = CSharpUtility.GetInt(worksheet.Cells(rowCount, 10).Text); Ability.过载 = CSharpUtility.GetInt(worksheet.Cells(rowCount, 11).Text); Ability.是否启用 = true; rowCount++; //当前行肯定是选择条件 Ability.效果选择类型 = CSharpUtility.GetEnum<SpellCard.效果选择类型枚举>(worksheet.Cells(rowCount, 3).Text, SpellCard.效果选择类型枚举.无需选择); Ability.FirstAbilityDefine.描述 = worksheet.Cells(rowCount, 4).Text; Ability.SecondAbilityDefine.描述 = worksheet.Cells(rowCount, 5).Text; rowCount++; GetAbilityDefine(ref Ability.FirstAbilityDefine, worksheet, ref rowCount); if (Ability.效果选择类型 != SpellCard.效果选择类型枚举.无需选择) { rowCount++; //当前行是第一效果的标题栏 GetAbilityDefine(ref Ability.SecondAbilityDefine, worksheet, ref rowCount); } switch (exportType) { case SystemManager.ExportType.XML: XmlSerializer xml = new XmlSerializer(typeof(SpellCard)); string XmlFilename = ExportFolderPicker.SelectedPathOrFileName + "\\Ability\\" + Ability.序列号 + ".xml"; xml.Serialize(new StreamWriter(XmlFilename), Ability); break; case SystemManager.ExportType.JSON: string JSonFilename = ExportFolderPicker.SelectedPathOrFileName + "\\Ability\\" + Ability.序列号 + ".json"; StreamWriter json = new StreamWriter(JSonFilename); json.Write(Ability.ToJson()); json.Close(); break; default: break; } rowCount++; } }