diff --git a/DungeonShooting_Art/effect/Explosion.aseprite b/DungeonShooting_Art/effect/Explosion.aseprite new file mode 100644 index 0000000..35ef5ef --- /dev/null +++ b/DungeonShooting_Art/effect/Explosion.aseprite Binary files differ diff --git a/DungeonShooting_Art/effect/Explosion.png b/DungeonShooting_Art/effect/Explosion.png new file mode 100644 index 0000000..dab1f49 --- /dev/null +++ b/DungeonShooting_Art/effect/Explosion.png Binary files differ diff --git a/DungeonShooting_Art/ui/GUI/CursorCenter.png b/DungeonShooting_Art/ui/GUI/CursorCenter.png new file mode 100644 index 0000000..468ec82 --- /dev/null +++ b/DungeonShooting_Art/ui/GUI/CursorCenter.png Binary files differ diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Automation.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Automation.cs index e8b7e51..576b44f 100644 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Automation.cs +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Automation.cs @@ -1,64 +1,16 @@ #if TOOLS -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text.Json; -using System.Text.RegularExpressions; +using Generator; using Godot; -using File = System.IO.File; [Tool] public partial class Automation : Control { - //支持后缀 - private string[] suffix = - { - ".png", ".jpg", ".txt", ".json", ".ini", ".tscn", ".tres", ".otf", ".gdshader", ".ogg", ".mp3", ".wav", ".svg" - }; - //排除第一层的文件夹 - private string[] exclude = - { - ".vscode", ".idea", ".git", ".import", ".mono", "android", "addons", ".godot" - }; - private string currDir = System.Environment.CurrentDirectory; - - private string resultStr = ""; - /// /// 更新 ResourcePath /// private void _on_Button_pressed() { - resultStr = "/// \n" + - "/// 编辑器下所有资源路径, 该类为 Automation 面板下自动生成的, 请不要手动编辑!\n" + - "/// \n" + - "public class ResourcePath\n" + - "{\n"; - - GD.Print("更新 ResourcePath..."); - - var directoryInfo = new DirectoryInfo(currDir); - - var directories = directoryInfo.GetDirectories(); - for (int i = 0; i < directories.Length; i++) - { - var directory = directories[i]; - if (!exclude.Contains(directory.Name)) - { - EachDir(directory); - } - } - - var fileInfos = directoryInfo.GetFiles(); - for (var i = 0; i < fileInfos.Length; i++) - { - HandleFile(fileInfos[i]); - } - - resultStr += "}"; - File.WriteAllText("src/game/manager/ResourcePath.cs", resultStr); - GD.Print("ResourcePath.cs 写出完成!"); + ResourcePathGenerator.Generate(); } /// @@ -66,139 +18,7 @@ /// private void _on_Button2_pressed() { - //地图路径 - var tileDir = DungeonRoomTemplate.RoomTileDir; - //地图描述数据路径 - var tileDataDir = DungeonRoomTemplate.RoomTileDataDir; - - var tileDirInfo = new DirectoryInfo(tileDir); - var tileDataDirInfo = new DirectoryInfo(tileDataDir); - - //所有地图列表 - var mapList = new HashSet(); - - //收集所有名称 - var fileDataInfos = tileDataDirInfo.GetFiles(); - foreach (var fileInfo in fileDataInfos) - { - mapList.Add(RemoveExtension(fileInfo.Name)); - } - //收集所有名称 - var fileInfos = tileDirInfo.GetFiles(); - foreach (var fileInfo in fileInfos) - { - if (fileInfo.Extension == ".tscn") - { - mapList.Add(RemoveExtension(fileInfo.Name)); - } - } - - //剔除多余的 tile.json - var arrays = mapList.ToArray(); - foreach (var item in arrays) - { - if (!File.Exists(tileDir + item + ".tscn")) - { - mapList.Remove(item); - var filePath = tileDataDir + item + ".json"; - if (File.Exists(filePath)) - { - GD.Print($"未找到'{tileDir + item}.tscn', 删除配置文件: {filePath}"); - File.Delete(filePath); - } - } - } - - //手动生成缺失的 tile.json - foreach (var item in mapList) - { - if (!File.Exists(tileDataDir + item + ".json")) - { - var tscnName = tileDir + item + ".tscn"; - var packedScene = ResourceManager.Load(tscnName, false); - if (packedScene != null) - { - var dungeonRoomTemplate = packedScene.Instantiate(); - var usedRect = dungeonRoomTemplate.GetUsedRect(); - var dungeonTile = new DungeonTile(dungeonRoomTemplate); - dungeonTile.SetFloorAtlasCoords(new List() { new Vector2I(0, 8) }); - //计算导航网格 - dungeonTile.GenerateNavigationPolygon(0); - var polygonData = dungeonTile.GetPolygonData(); - DungeonRoomTemplate.SaveConfig(new List(), usedRect.Position, usedRect.Size, polygonData.ToList(), item); - dungeonRoomTemplate.QueueFree(); - } - } - } - - var list = new List(); - //整合操作 - foreach (var item in mapList) - { - var configPath = tileDataDir + item + ".json"; - var configText = File.ReadAllText(configPath); - var roomInfo = DungeonRoomTemplate.DeserializeDungeonRoomInfo(configText); - var split = new DungeonRoomSplit(); - split.ScenePath = ToResPath(tileDir + item + ".tscn"); - split.ConfigPath = ToResPath(configPath); - split.RoomInfo = roomInfo; - list.Add(split); - } - - //写出配置 - var config = new JsonSerializerOptions(); - config.WriteIndented = true; - var text = JsonSerializer.Serialize(list, config); - File.WriteAllText(DungeonRoomTemplate.RoomTileConfigFile, text); - - GD.Print("地牢房间配置, 重新打包完成!"); - } - - private void EachDir(DirectoryInfo directoryInfos) - { - var fileInfos = directoryInfos.GetFiles(); - for (var i = 0; i < fileInfos.Length; i++) - { - HandleFile(fileInfos[i]); - } - - var directories = directoryInfos.GetDirectories(); - for (var i = 0; i < directories.Length; i++) - { - EachDir(directories[i]); - } - } - - private void HandleFile(FileInfo fileInfo) - { - if (suffix.Contains(fileInfo.Extension)) - { - var field = fileInfo.FullName.Substring(currDir.Length + 1); - field = field.Replace("\\", "/"); - var resPath = "res://" + field; - field = field.Replace(".", "_"); - field = field.Replace("/", "_"); - field = Regex.Replace(field, "[^\\w_]", ""); - resultStr += $" public const string {field} = \"{resPath}\";\n"; - } - } - - private string ToResPath(string path) - { - var field = path.Substring(currDir.Length + 1); - field = field.Replace("\\", "/"); - return "res://" + field; - } - - private string RemoveExtension(string name) - { - var index = name.LastIndexOf(".", StringComparison.Ordinal); - if (index >= 0) - { - return name.Substring(0, index); - } - - return name; + RoomPackGenerator.Generate(); } } #endif \ No newline at end of file diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg new file mode 100644 index 0000000..77c8e18 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg.import b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg.import new file mode 100644 index 0000000..5bf5cd9 --- /dev/null +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Mark.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://deg6b3kqkdwbn" +path="res://.godot/imported/Mark.svg-9f2b1d4ccb36e421ac6045818f744145.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/dungeonShooting_plugin/Mark.svg" +dest_files=["res://.godot/imported/Mark.svg-9f2b1d4ccb36e421ac6045818f744145.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs index 2db2e91..10ccbeb 100644 --- a/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs +++ b/DungeonShooting_Godot/addons/dungeonShooting_plugin/Plugin.cs @@ -27,6 +27,16 @@ var texture2 = GD.Load("res://addons/dungeonShooting_plugin/Map.svg"); AddCustomType("DungeonRoomTemplate", "TileMap", script2, texture2); + var script3 = GD.Load