Пример #1
0
 /// <summary>
 /// 获得法术定义
 /// </summary>
 /// <param name="worksheet"></param>
 /// <param name="rowCount"></param>
 /// <returns></returns>
 private static void GetAbilityDefine(ref SpellCard.AbilityDefine Ability, dynamic worksheet, ref int rowCount)
 {
     Ability.MainAbilityDefine = GetEffectDefine(worksheet, ref rowCount);
     //追加效果
     string NextLine = worksheet.Cells(rowCount + 1, 2).Text;
     if (!string.IsNullOrEmpty(NextLine) && NextLine == "追加条件")
     {
         rowCount++;
         //当前行是追加条件
         Ability.AppendEffectCondition = worksheet.Cells(rowCount, 3).Text;
         rowCount++;
         //当前行是第一效果的标题栏
         Ability.AppendAbilityDefine = GetEffectDefine(worksheet, ref rowCount);
     }
 }
Пример #2
0
 /// <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++;
     }
 }