提交示例代码
This commit is contained in:
BIN
物品和背包的完整代码/Config/Excel/#ConstValue.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/#ConstValue.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/.DS_Store
vendored
Normal file
BIN
物品和背包的完整代码/Config/Excel/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/ContainerConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/ContainerConfig.xlsx
Normal file
Binary file not shown.
6
物品和背包的完整代码/Config/Excel/Custom.txt
Normal file
6
物品和背包的完整代码/Config/Excel/Custom.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
// 自定义导出配置文件,用于配置自定义导出自定义程序的路径,每行一个路径,路径是导表应用的相对路径。如:../../Config/Custom/1.cs
|
||||
../../Config/Excel/Custom/ErrorCodeToConst.cs
|
||||
../../Config/Excel/Custom/ConstValueToConst.cs
|
||||
../../Config/Excel/Custom/ItemTypeToEnum.cs
|
||||
../../Config/Excel/Custom/ItemUseEffectToEnum.cs
|
||||
../../Config/Excel/Custom/ContainerConfigToEnum.cs
|
||||
148
物品和背包的完整代码/Config/Excel/Custom/ConstValueToConst.cs
Normal file
148
物品和背包的完整代码/Config/Excel/Custom/ConstValueToConst.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public class ConstValueToConst : ACustomExport
|
||||
{
|
||||
private class ConstValueInfo
|
||||
{
|
||||
public string Name;
|
||||
public string Type;
|
||||
public string Value;
|
||||
public string Remark;
|
||||
}
|
||||
[Flags]
|
||||
private enum ExportType
|
||||
{
|
||||
None = 0,
|
||||
Server = 1,
|
||||
Client = 1 << 1,
|
||||
All = Server | Client
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!ExcelExporter.IgnoreTable.TryGetValue("#ConstValue", out var constValuePath))
|
||||
{
|
||||
Log.Error("ConstValue is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var serverDic = new List<ConstValueInfo>();
|
||||
var clientDic = new List<ConstValueInfo>();
|
||||
var excelWorksheet = ExcelExporter.LoadExcel(constValuePath, false);
|
||||
|
||||
for (int row = 2; row <= excelWorksheet.Dimension.Rows; row++)
|
||||
{
|
||||
var exportType = ExportType.All;
|
||||
var exportTypeStr = excelWorksheet.GetCellValue(row, 1);
|
||||
|
||||
if (!string.IsNullOrEmpty(exportTypeStr))
|
||||
{
|
||||
exportType = ExportType.None;
|
||||
exportTypeStr = exportTypeStr.ToUpper();
|
||||
|
||||
if (exportTypeStr.Contains("S"))
|
||||
{
|
||||
exportType |= ExportType.Server;
|
||||
}
|
||||
|
||||
if (exportTypeStr.Contains("C"))
|
||||
{
|
||||
exportType |= ExportType.Client;
|
||||
}
|
||||
}
|
||||
|
||||
var constValueInfo = new ConstValueInfo()
|
||||
{
|
||||
Name = excelWorksheet.GetCellValue(row, 2),
|
||||
Type = excelWorksheet.GetCellValue(row, 3),
|
||||
Value = excelWorksheet.GetCellValue(row, 4),
|
||||
Remark = excelWorksheet.GetCellValue(row, 5)
|
||||
};
|
||||
|
||||
if (exportType.HasFlag(ExportType.Server))
|
||||
{
|
||||
serverDic.Add(constValueInfo);
|
||||
}
|
||||
|
||||
if (exportType.HasFlag(ExportType.Client))
|
||||
{
|
||||
clientDic.Add(constValueInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (serverDic.Count > 0)
|
||||
{
|
||||
Write(serverDic, CustomExportType.Server);
|
||||
}
|
||||
|
||||
if (clientDic.Count > 0)
|
||||
{
|
||||
Write(clientDic, CustomExportType.Client);
|
||||
}
|
||||
}
|
||||
|
||||
private void Write(List<ConstValueInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在#ConstValue.xsl里。");
|
||||
strBuilder.AppendLine("\tpublic partial class ConstValue\n\t{");
|
||||
foreach (var constValueInfo in dic)
|
||||
{
|
||||
var remark = string.IsNullOrEmpty(constValueInfo.Remark) ? constValueInfo.Name : constValueInfo.Remark;
|
||||
strBuilder.AppendLine($"\t\t/// <summary>\n\t\t/// {remark}\n\t\t/// </summary>");
|
||||
strBuilder.AppendLine(
|
||||
$"\t\tpublic const {constValueInfo.Type} {constValueInfo.Name} = {DefaultValue(constValueInfo.Type, constValueInfo.Value)};");
|
||||
}
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ConstValue.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
|
||||
private static string DefaultValue(string type, string value)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "byte[]":
|
||||
case "int[]":
|
||||
case "long[]":
|
||||
case "string[]":
|
||||
case "double[]":
|
||||
case "float[]":
|
||||
return $"new {type} {{{value}}}";
|
||||
case "byte[,]":
|
||||
case "int[,]":
|
||||
case "long[,]":
|
||||
case "string[,]":
|
||||
case "float[,]":
|
||||
case "double[,]":
|
||||
return $"new {type} {{{value}}}";
|
||||
case "int":
|
||||
case "bool":
|
||||
case "uint":
|
||||
case "long":
|
||||
case "double":
|
||||
return $"{value}";
|
||||
case "float":
|
||||
return value[^1] == 'f' ? value : $"{value}f";
|
||||
case "string":
|
||||
return $"\"{value}\"";
|
||||
case "Vector2":
|
||||
{
|
||||
var strings = value.Split(',', StringSplitOptions.TrimEntries);
|
||||
return $"new Vector2({strings[0]},{strings[1]})";
|
||||
}
|
||||
case "Vector3":
|
||||
{
|
||||
var strings = value.Split(',', StringSplitOptions.TrimEntries);
|
||||
return $"new Vector3({strings[0]},{strings[1]},{strings[2]})";
|
||||
}
|
||||
default:
|
||||
throw new Exception($"不支持此类型: {type}");
|
||||
}
|
||||
}
|
||||
}
|
||||
62
物品和背包的完整代码/Config/Excel/Custom/ContainerConfigToEnum.cs
Normal file
62
物品和背包的完整代码/Config/Excel/Custom/ContainerConfigToEnum.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Text;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public class ContainerConfigToEnum : ACustomExport
|
||||
{
|
||||
private class ContainerConfigInfo
|
||||
{
|
||||
public int Type;
|
||||
public string Name;
|
||||
public string Descride;
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!Worksheets.TryGetValue("ContainerConfig", out var containerConfig))
|
||||
{
|
||||
Log.Info("ContainerConfig is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dic = new List<ContainerConfigInfo>();
|
||||
|
||||
for (int row = 7; row <= containerConfig.Dimension.Rows; row++)
|
||||
{
|
||||
var containerName = containerConfig.GetCellValue(row, 4);
|
||||
var containerType = containerConfig.GetCellValue(row, 6);
|
||||
var containerDes = containerConfig.GetCellValue(row, 5);
|
||||
|
||||
dic.Add(new ContainerConfigInfo()
|
||||
{
|
||||
Type = int.Parse(containerType),
|
||||
Name = containerName,
|
||||
Descride = containerDes,
|
||||
});
|
||||
}
|
||||
|
||||
Write(dic, CustomExportType.Server);
|
||||
Write(dic, CustomExportType.Client);
|
||||
}
|
||||
|
||||
private void Write(List<ContainerConfigInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("using System;\n");
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在ContainerConfig.xsl里。");
|
||||
strBuilder.AppendLine("\t[Flags]");
|
||||
strBuilder.AppendLine("\tpublic enum ContainerType : byte\n\t{");
|
||||
strBuilder.AppendLine("\t\tNone = 0,");
|
||||
foreach (var constValueInfo in dic)
|
||||
{
|
||||
strBuilder.AppendLine($"\t\t{constValueInfo.Name} = {constValueInfo.Type},// {constValueInfo.Descride}");
|
||||
}
|
||||
strBuilder.AppendLine("\t\tCell = Equip | Trade,// 按格子存储的容器");
|
||||
strBuilder.AppendLine("\t\tNormal = Bag,// 正常的容器");
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ContainerType.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
56
物品和背包的完整代码/Config/Excel/Custom/ErrorCodeToConst.cs
Normal file
56
物品和背包的完整代码/Config/Excel/Custom/ErrorCodeToConst.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Text;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public class ErrorCodeToConst : ACustomExport
|
||||
{
|
||||
private class ErrorCodeInfo
|
||||
{
|
||||
public uint Id;
|
||||
public string Name;
|
||||
public string Text;
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!Worksheets.TryGetValue("ErrorCode", out var errorCodeConfig))
|
||||
{
|
||||
Log.Info("ErrorCode is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dic = new List<ErrorCodeInfo>();
|
||||
for (var row = 7; row <= errorCodeConfig.Dimension.Rows; row++)
|
||||
{
|
||||
var errorCodeInfo = new ErrorCodeInfo()
|
||||
{
|
||||
Id = uint.Parse( errorCodeConfig.GetCellValue(row, 3)),
|
||||
Name = errorCodeConfig.GetCellValue(row, 4),
|
||||
Text = errorCodeConfig.GetCellValue(row, 5)
|
||||
};
|
||||
dic.Add(errorCodeInfo);
|
||||
}
|
||||
|
||||
Write(dic, CustomExportType.Server);
|
||||
Write(dic, CustomExportType.Client);
|
||||
}
|
||||
|
||||
private void Write(List<ErrorCodeInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在ErrorCode.xsl里。");
|
||||
strBuilder.AppendLine("\tpublic partial class ErrorCode\n\t{");
|
||||
|
||||
foreach (var errorCodeInfo in dic)
|
||||
{
|
||||
strBuilder.AppendLine($"\t\t/// <summary>\n\t\t/// {errorCodeInfo.Text}\n\t\t/// </summary>");
|
||||
strBuilder.AppendLine($"\t\tpublic const uint {errorCodeInfo.Name} = {errorCodeInfo.Id};");
|
||||
}
|
||||
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ErrorCode.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
60
物品和背包的完整代码/Config/Excel/Custom/ItemTypeToEnum.cs
Normal file
60
物品和背包的完整代码/Config/Excel/Custom/ItemTypeToEnum.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public sealed class ItemTypeToEnum : ACustomExport
|
||||
{
|
||||
private class ItemTypeInfo
|
||||
{
|
||||
public int Index;
|
||||
public string Name;
|
||||
public string Descride;
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!ExcelExporter.IgnoreTable.TryGetValue("#ItemType", out var itemTypePath))
|
||||
{
|
||||
Log.Error("#ItemType is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dic = new List<ItemTypeInfo>();
|
||||
var excelWorksheet = ExcelExporter.LoadExcel(itemTypePath, false);
|
||||
for (int row = 2; row <= excelWorksheet.Dimension.Rows; row++)
|
||||
{
|
||||
var exportIndex = excelWorksheet.GetCellValue(row, 1);
|
||||
if (string.IsNullOrEmpty(exportIndex))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dic.Add(new ItemTypeInfo()
|
||||
{
|
||||
Index = int.Parse(exportIndex),
|
||||
Name = excelWorksheet.GetCellValue(row, 2),
|
||||
Descride = excelWorksheet.GetCellValue(row, 3),
|
||||
});
|
||||
}
|
||||
|
||||
Write(dic, CustomExportType.Server);
|
||||
Write(dic, CustomExportType.Client);
|
||||
}
|
||||
|
||||
private void Write(List<ItemTypeInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在#ItemType.xsl里。");
|
||||
strBuilder.AppendLine("\tpublic enum ItemType\n\t{");
|
||||
strBuilder.AppendLine("\t\tNone = 0,");
|
||||
foreach (var constValueInfo in dic)
|
||||
{
|
||||
strBuilder.AppendLine($"\t\t{constValueInfo.Name} = {constValueInfo.Index},// {constValueInfo.Descride}");
|
||||
}
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ItemType.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
60
物品和背包的完整代码/Config/Excel/Custom/ItemUseEffectToEnum.cs
Normal file
60
物品和背包的完整代码/Config/Excel/Custom/ItemUseEffectToEnum.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using Fantasy.Exporter;
|
||||
using Fantasy.Tools.ConfigTable;
|
||||
|
||||
namespace Exporter;
|
||||
|
||||
public sealed class ItemUseEffectToEnum : ACustomExport
|
||||
{
|
||||
private class ItemUseEffectInfo
|
||||
{
|
||||
public int Index;
|
||||
public string Name;
|
||||
public string Descride;
|
||||
}
|
||||
public override void Run()
|
||||
{
|
||||
if (!ExcelExporter.IgnoreTable.TryGetValue("#ItemUseEffect", out var itemTypePath))
|
||||
{
|
||||
Log.Error("ItemUseEffect is null");
|
||||
return;
|
||||
}
|
||||
|
||||
var dic = new List<ItemUseEffectInfo>();
|
||||
var excelWorksheet = ExcelExporter.LoadExcel(itemTypePath, false);
|
||||
for (int row = 2; row <= excelWorksheet.Dimension.Rows; row++)
|
||||
{
|
||||
var exportIndex = excelWorksheet.GetCellValue(row, 1);
|
||||
if (string.IsNullOrEmpty(exportIndex))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
dic.Add(new ItemUseEffectInfo()
|
||||
{
|
||||
Index = int.Parse(exportIndex),
|
||||
Name = excelWorksheet.GetCellValue(row, 2),
|
||||
Descride = excelWorksheet.GetCellValue(row, 3),
|
||||
});
|
||||
}
|
||||
|
||||
Write(dic, CustomExportType.Server);
|
||||
Write(dic, CustomExportType.Client);
|
||||
}
|
||||
|
||||
private void Write(List<ItemUseEffectInfo> dic, CustomExportType customExportType)
|
||||
{
|
||||
var strBuilder = new StringBuilder();
|
||||
strBuilder.AppendLine("namespace Fantasy\n{");
|
||||
strBuilder.AppendLine("\t// 生成器自动生成,请不要手动编辑,修改请在#ItemUseEffect.xsl里。");
|
||||
strBuilder.AppendLine("\tpublic enum ItemUseEffect\n\t{");
|
||||
strBuilder.AppendLine("\t\tNone = 0,");
|
||||
foreach (var constValueInfo in dic)
|
||||
{
|
||||
strBuilder.AppendLine($"\t\t{constValueInfo.Name} = {constValueInfo.Index},// {constValueInfo.Descride}");
|
||||
}
|
||||
strBuilder.AppendLine("\t}\n}");
|
||||
Write("ItemUseEffect.cs", strBuilder.ToString(), customExportType);
|
||||
}
|
||||
}
|
||||
BIN
物品和背包的完整代码/Config/Excel/ErrorCode.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/ErrorCode.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/#ItemType.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/#ItemType.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/#ItemUseEffect.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/#ItemUseEffect.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/.DS_Store
vendored
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/.DS_Store
vendored
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipAffixConfig.xlsm
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipAffixConfig.xlsm
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipEntryConfig.xlsm
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipEntryConfig.xlsm
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipValueConfig.xlsm
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/Equip/EquipValueConfig.xlsm
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/ItemConfig_Drug.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/ItemConfig_Drug.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Item/ItemConfig_Equip.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Item/ItemConfig_Equip.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/LevelConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/LevelConfig.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Server/MachineConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Server/MachineConfig.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Server/ProcessConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Server/ProcessConfig.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Server/SceneConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Server/SceneConfig.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Server/WorldConfig.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Server/WorldConfig.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Unit/.DS_Store
vendored
Normal file
BIN
物品和背包的完整代码/Config/Excel/Unit/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_Monster.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_Monster.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_NPC.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_NPC.xlsx
Normal file
Binary file not shown.
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_Player.xlsx
Normal file
BIN
物品和背包的完整代码/Config/Excel/Unit/UnitConfig_Player.xlsx
Normal file
Binary file not shown.
1
物品和背包的完整代码/Config/Excel/Version.txt
Normal file
1
物品和背包的完整代码/Config/Excel/Version.txt
Normal file
@@ -0,0 +1 @@
|
||||
{"WorksheetNames":["LevelConfig","ContainerConfig","EquipAffixConfig","MachineConfig","ProcessConfig","ErrorCode","ItemConfig_Drug","UnitConfig_Monster","WorldConfig","UnitConfig_NPC","ItemConfig_Equip","UnitConfig_Player","EquipValueConfig","EquipEntryConfig","SceneConfig","SceneTypeConfig"],"Tables":{"ErrorCode":1743067797553,"LevelConfig":1743003386521,"ContainerConfig":1745421515852,"UnitConfig_NPC":1742985157502,"UnitConfig_Player":1745918312114,"UnitConfig_Monster":1742985381203,"MachineConfig":1742224599000,"SceneConfig":1743618691132,"WorldConfig":1743413221256,"ProcessConfig":1742224599000,"ItemConfig_Drug":1745943712301,"ItemConfig_Equip":1747148981281,"EquipAffixConfig":1747129966512,"EquipValueConfig":1746993412781,"EquipEntryConfig":1747129308542}}
|
||||
Reference in New Issue
Block a user