diff --git a/DungeonShooting_Godot/excel/Role.xlsx b/DungeonShooting_Godot/excel/Role.xlsx index 07a0d37..b02e664 100644 --- a/DungeonShooting_Godot/excel/Role.xlsx +++ b/DungeonShooting_Godot/excel/Role.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/Weapon.xlsx b/DungeonShooting_Godot/excel/Weapon.xlsx index 2c52486..b333b3f 100644 --- a/DungeonShooting_Godot/excel/Weapon.xlsx +++ b/DungeonShooting_Godot/excel/Weapon.xlsx Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/gun/weapon0001/weapon0001.png.import b/DungeonShooting_Godot/resource/sprite/gun/weapon0001/weapon0001.png.import index 39572c3..b4c2034 100644 --- a/DungeonShooting_Godot/resource/sprite/gun/weapon0001/weapon0001.png.import +++ b/DungeonShooting_Godot/resource/sprite/gun/weapon0001/weapon0001.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://civvcowt2wklr" -path="res://.godot/imported/Weapon0001.png-305a0d14fe3c147edd264f33dc26bc8a.ctex" +path="res://.godot/imported/weapon0001.png-6f3807222cc10bbb7eddc649cd3775c0.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://resource/sprite/gun/weapon0001/Weapon0001.png" -dest_files=["res://.godot/imported/Weapon0001.png-305a0d14fe3c147edd264f33dc26bc8a.ctex"] +source_file="res://resource/sprite/gun/weapon0001/weapon0001.png" +dest_files=["res://.godot/imported/weapon0001.png-6f3807222cc10bbb7eddc649cd3775c0.ctex"] [params] diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import index c36be94..b20c9a6 100644 --- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://chd2vtesap5cf" -path="res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex" +path="res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://resource/sprite/role/enemy0001/Enemy0001.png" -dest_files=["res://.godot/imported/Enemy0001.png-148a38dfa95953b26d890356e8875de4.ctex"] +source_file="res://resource/sprite/role/enemy0001/enemy0001.png" +dest_files=["res://.godot/imported/enemy0001.png-1247a3ddf8a1a163d812cad12c4340fd.ctex"] [params] diff --git a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import index d563acf..56388a2 100644 --- a/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/enemy0001/enemy0001_Debris.png.import @@ -3,15 +3,15 @@ importer="texture" type="CompressedTexture2D" uid="uid://d2f55lu60x64i" -path="res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex" +path="res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex" metadata={ "vram_texture": false } [deps] -source_file="res://resource/sprite/role/enemy0001/Enemy0001_Debris.png" -dest_files=["res://.godot/imported/Enemy0001_Debris.png-ac416dc79cd3c1217b27e1ef1fbe0d0b.ctex"] +source_file="res://resource/sprite/role/enemy0001/enemy0001_Debris.png" +dest_files=["res://.godot/imported/enemy0001_Debris.png-297a2fb6680cb862a9a085cf58f8268c.ctex"] [params] diff --git a/DungeonShooting_Godot/src/config/Role.cs b/DungeonShooting_Godot/src/config/Role.cs index 964df76..9e42b44 100644 --- a/DungeonShooting_Godot/src/config/Role.cs +++ b/DungeonShooting_Godot/src/config/Role.cs @@ -1,6 +1,6 @@ namespace Config; -public class Role +public class Role { /// /// 物体唯一id
@@ -8,4 +8,10 @@ ///
public string Id; + public Role Clone() + { + var inst = new Role(); + inst.Id = Id; + return inst; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/config/Weapon.cs b/DungeonShooting_Godot/src/config/Weapon.cs index 7a48e08..535b077 100644 --- a/DungeonShooting_Godot/src/config/Weapon.cs +++ b/DungeonShooting_Godot/src/config/Weapon.cs @@ -1,6 +1,6 @@ namespace Config; -public class Weapon +public class Weapon { /// /// 物体唯一id
@@ -209,6 +209,52 @@ /// /// 投抛状态下物体碰撞器大小 /// - public Godot.Vector2 ThrowCollisionSize; + public SerializeVector2 ThrowCollisionSize; + public Weapon Clone() + { + var inst = new Weapon(); + inst.Id = Id; + inst.Prefab = Prefab; + inst.Weight = Weight; + inst.Name = Name; + inst.Icon = Icon; + inst.WeightType = WeightType; + inst.ContinuousShoot = ContinuousShoot; + inst.AmmoCapacity = AmmoCapacity; + inst.MaxAmmoCapacity = MaxAmmoCapacity; + inst.StandbyAmmoCapacity = StandbyAmmoCapacity; + inst.ReloadTime = ReloadTime; + inst.AloneReload = AloneReload; + inst.AloneReloadCount = AloneReloadCount; + inst.AloneReloadCanShoot = AloneReloadCanShoot; + inst.LooseShoot = LooseShoot; + inst.MinChargeTime = MinChargeTime; + inst.MinContinuousCount = MinContinuousCount; + inst.MaxContinuousCount = MaxContinuousCount; + inst.TriggerInterval = TriggerInterval; + inst.StartFiringSpeed = StartFiringSpeed; + inst.FinalFiringSpeed = FinalFiringSpeed; + inst.FiringSpeedAddSpeed = FiringSpeedAddSpeed; + inst.FiringSpeedBackSpeed = FiringSpeedBackSpeed; + inst.MinFireBulletCount = MinFireBulletCount; + inst.MaxFireBulletCount = MaxFireBulletCount; + inst.DelayedTime = DelayedTime; + inst.StartScatteringRange = StartScatteringRange; + inst.FinalScatteringRange = FinalScatteringRange; + inst.ScatteringRangeAddValue = ScatteringRangeAddValue; + inst.ScatteringRangeBackSpeed = ScatteringRangeBackSpeed; + inst.ScatteringRangeBackTime = ScatteringRangeBackTime; + inst.MaxDistance = MaxDistance; + inst.MinDistance = MinDistance; + inst.MaxBacklash = MaxBacklash; + inst.MinBacklash = MinBacklash; + inst.BacklashRegressionSpeed = BacklashRegressionSpeed; + inst.UpliftAngle = UpliftAngle; + inst.DefaultAngle = DefaultAngle; + inst.UpliftAngleRestore = UpliftAngleRestore; + inst.BulletId = BulletId; + inst.ThrowCollisionSize = ThrowCollisionSize; + return inst; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs index da65dab..8b117dc 100644 --- a/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/ExcelGenerator.cs @@ -1,5 +1,6 @@ using System.Data; using System.IO; +using System.Linq; using Godot; using NPOI.XSSF.UserModel; @@ -7,13 +8,18 @@ public static class ExcelGenerator { - // private class ExcelTableData - // { - // public string[] ColumnName; - // public string[] TypeName; - // public string[][] Data; - // } - + //关键字列表 + private static readonly string[] Keywords = + { + "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const", + "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern", + "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface", + "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override", "params", + "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short", "sizeof", + "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof", "uint", "ulong", + "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while" + }; + public static bool ExportExcel() { GD.Print("准备导出excel表..."); @@ -38,16 +44,18 @@ { var fileName = Path.GetFileNameWithoutExtension(excelPath).FirstToUpper(); var outStr = "namespace Config;\n\n"; - outStr += $"public class {fileName} \n{{\n"; + outStr += $"public class {fileName}\n{{\n"; + var cloneFuncStr = $" public {fileName} Clone()\n {{\n"; + cloneFuncStr += $" var inst = new {fileName}();\n"; var sourceFile = excelPath; - + //加载表数据 var workbook = new XSSFWorkbook(sourceFile); var sheet1 = workbook.GetSheet("Sheet1"); //解析表 var rowCount = sheet1.LastRowNum; - + //先解析表中的列名, 注释, 类型 var columnCount = -1; var names = sheet1.GetRow(0); @@ -63,7 +71,7 @@ } value = value.FirstToUpper(); - + outStr += $" /// \n"; var descriptionCell = descriptions.GetCell(cell.ColumnIndex); var description = descriptionCell.StringCellValue.Replace("\n", "
\n /// "); @@ -71,8 +79,12 @@ outStr += $" /// {description}\n"; outStr += $" ///
\n"; outStr += $" public {type} {value};\n\n"; + cloneFuncStr += $" inst.{value} = {value};\n"; } + cloneFuncStr += " return inst;\n"; + cloneFuncStr += " }\n"; + outStr += cloneFuncStr; outStr += "}"; workbook.Close(); @@ -80,6 +92,7 @@ { Directory.CreateDirectory("src/config"); } + File.WriteAllText("src/config/" + fileName + ".cs", outStr); } @@ -98,4 +111,9 @@ return typeName; } + + public static bool IsCSharpKeyword(string str) + { + return Keywords.Contains(str); + } } \ No newline at end of file