diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn index b6154e8..f486d98 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn @@ -1,16 +1,14 @@ -[gd_scene load_steps=12 format=3 uid="uid://dfqb73y4br8yd"] +[gd_scene load_steps=10 format=3 uid="uid://dfqb73y4br8yd"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs" id="1_6jjk7"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/down/TileEditArea.cs" id="2_ynf0r"] [ext_resource type="Script" path="res://src/game/common/ui/EditorMaskBrush.cs" id="3_gydh0"] -[ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/down/TerrainCellDragHandler.cs" id="3_ssd86"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs" id="5_0x7yx"] [ext_resource type="Texture2D" uid="uid://d2wslibovwv7w" path="res://resource/sprite/ui/commonIcon/CenterTool.png" id="5_08bc4"] [ext_resource type="Texture2D" uid="uid://bud6ah5xyey37" path="res://resource/sprite/map/TerrainMask2.png" id="5_xabgh"] [ext_resource type="Texture2D" uid="uid://chisfq2alcq16" path="res://resource/sprite/map/TerrainMask3.png" id="6_vmj5y"] [ext_resource type="Texture2D" uid="uid://cvjj6jnmxgprw" path="res://resource/sprite/map/TerrainMask.png" id="7_g8dxk"] [ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/up/TerrainBrush.cs" id="7_lmu64"] -[ext_resource type="Script" path="res://src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs" id="8_7xxcq"] [node name="TileSetEditorTerrain" type="Control"] layout_mode = 3 @@ -20,7 +18,6 @@ grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_6jjk7") -Layer = null [node name="VSplitContainer" type="VSplitContainer" parent="."] layout_mode = 1 @@ -84,7 +81,6 @@ offset_right = 16.0 offset_bottom = 16.0 mouse_filter = 1 -script = ExtResource("8_7xxcq") [node name="CellTexture" type="Sprite2D" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot/CellRoot/RightCell"] centered = false @@ -221,12 +217,11 @@ offset_bottom = 1.0 mouse_filter = 2 -[node name="BottomCell" type="TextureButton" parent="VSplitContainer/PanelBottom/MarginContainer/BottomBg/TileTexture/CellRoot"] -layout_mode = 0 +[node name="BottomCell" type="Control" parent="VSplitContainer/PanelBottom/MarginContainer/BottomBg/TileTexture/CellRoot"] +anchors_preset = 0 offset_right = 16.0 offset_bottom = 16.0 mouse_filter = 1 -script = ExtResource("3_ssd86") [node name="MaskBrush" type="Control" parent="VSplitContainer/PanelBottom/MarginContainer/BottomBg/TileTexture"] layout_mode = 1 @@ -262,3 +257,7 @@ texture_normal = ExtResource("5_08bc4") ignore_texture_size = true stretch_mode = 5 + +[node name="DragSprite" type="Sprite2D" parent="."] +z_index = 10 +region_enabled = true diff --git a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json index a4acaf9..41a2530 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json @@ -7,8 +7,18 @@ "Path": "resource/map/tileMaps/Test1/battle/Battle1" } ], - "InletList": [], - "OutletList": [], + "InletList": [ + { + "ErrorType": 0, + "Path": "resource/map/tileMaps/Test1/inlet/Start1" + } + ], + "OutletList": [ + { + "ErrorType": 0, + "Path": "resource/map/tileMaps/Test1/outlet/End1" + } + ], "BossList": [], "RewardList": [], "ShopList": [], diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png index 7db44f0..ad3a817 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png.import b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png.import new file mode 100644 index 0000000..cfe8193 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preview.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://wvfu2bwf6m7t" +path="res://.godot/imported/Preview.png-c3396b369b426836d0fe1b15b21c3825.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileMaps/Test1/battle/Battle1/Preview.png" +dest_files=["res://.godot/imported/Preview.png-c3396b369b426836d0fe1b15b21c3825.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 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/RoomInfo.json index 5eac39c..e8c9e2f 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/RoomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/RoomInfo.json @@ -1 +1 @@ -{"Position":{"X":-3,"Y":-5},"Size":{"X":10,"Y":10},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":0,"RoomName":"Battle1","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-4,"Y":-8},"Size":{"X":16,"Y":14},"DoorAreaInfos":[{"Direction":3,"Start":0,"End":128},{"Direction":1,"Start":0,"End":64},{"Direction":2,"Start":80,"End":192},{"Direction":0,"Start":80,"End":144}],"GroupName":"Test1","RoomType":0,"RoomName":"Battle1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/TileInfo.json index e06b107..0d1b78c 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/TileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/TileInfo.json @@ -1 +1 @@ -{"NavigationVertices":[{"X":58,"Y":6},{"X":74,"Y":6},{"X":74,"Y":50},{"X":-10,"Y":50},{"X":-10,"Y":-26},{"X":58,"Y":-26}],"NavigationPolygon":[[0,1,2,3],[0,3,4,5]],"Floor":[-1,-1,0,3,-1,-2,0,3,0,-2,0,3,1,-2,0,3,2,-2,0,3,3,-2,0,3,3,-1,0,3,3,0,0,3,2,0,0,3,2,-1,0,3,1,-1,0,3,0,-1,0,3,0,0,0,3,-1,0,0,3,1,0,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,3,1,0,3,4,1,0,3,4,2,0,3,3,2,0,3,2,2,0,3,1,2,0,3,0,2,0,3,-1,2,0,3,4,0,0,3],"Middle":[-1,-4,63,1,-1,-3,0,2,0,-4,63,1,0,-3,0,2,1,-4,63,1,1,-3,0,2,2,-4,63,1,2,-3,0,2,3,-4,63,1,3,-3,0,2,4,-2,54,1,4,-1,0,2],"Top":[-3,-5,511,1,-3,-4,511,1,-3,-3,511,1,-3,-2,511,1,-3,-1,511,1,-3,0,511,1,-3,1,511,1,-3,2,511,1,-3,3,511,1,-3,4,511,1,-2,-5,511,1,-2,-4,255,1,-2,-3,219,1,-2,-2,219,1,-2,-1,219,1,-2,0,219,1,-2,1,219,1,-2,2,219,1,-2,3,507,1,-2,4,511,1,-1,-5,511,1,-1,3,504,1,-1,4,511,1,0,-5,511,1,0,3,504,1,0,4,511,1,1,-5,511,1,1,3,504,1,1,4,511,1,2,-5,511,1,2,3,504,1,2,4,511,1,3,-5,511,1,3,3,504,1,3,4,511,1,4,-5,511,1,4,-4,447,1,4,-3,438,1,4,3,504,1,4,4,511,1,5,-5,511,1,5,-4,511,1,5,-3,511,1,5,-2,447,1,5,-1,438,1,5,0,438,1,5,1,438,1,5,2,438,1,5,3,510,1,5,4,511,1,6,-3,511,1,6,-2,511,1,6,-1,511,1,6,0,511,1,6,1,511,1,6,2,511,1,6,3,511,1,6,4,511,1]} \ No newline at end of file +{"NavigationVertices":[{"X":154,"Y":6},{"X":154,"Y":66},{"X":134,"Y":38},{"X":138,"Y":6},{"X":134,"Y":-30},{"X":138,"Y":-58},{"X":90,"Y":-58},{"X":74,"Y":-30},{"X":118,"Y":54},{"X":118,"Y":38},{"X":54,"Y":66},{"X":74,"Y":54},{"X":54,"Y":50},{"X":-10,"Y":50},{"X":-10,"Y":-14},{"X":-26,"Y":-14},{"X":-26,"Y":-74},{"X":90,"Y":-74}],"NavigationPolygon":[[0,1,2,3],[3,2,4,5],[6,5,4,7],[8,9,2,1],[8,1,10,11],[11,10,12,7],[12,13,14,7],[7,14,15,16,17,6]],"Floor":[-1,-1,0,3,3,-1,0,3,3,0,0,3,2,0,0,3,2,-1,0,3,1,-1,0,3,0,-1,0,3,0,0,0,3,-1,0,0,3,1,0,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,3,1,0,3,4,1,0,3,4,2,0,3,3,2,0,3,2,2,0,3,1,2,0,3,0,2,0,3,-1,2,0,3,4,0,0,3,4,-1,0,3,4,-2,0,3,3,-2,0,3,2,-2,0,3,1,-2,0,3,0,-2,0,3,-1,-2,0,3,-1,-3,0,3,0,-3,0,3,1,-3,0,3,2,-3,0,3,3,-3,0,3,4,-3,0,3,5,-3,0,3,5,-4,0,3,5,-5,0,3,4,-5,0,3,3,-5,0,3,2,-5,0,3,1,-5,0,3,0,-5,0,3,-1,-5,0,3,-2,-5,0,3,-2,-4,0,3,-1,-4,0,3,0,-4,0,3,1,-4,0,3,2,-4,0,3,3,-4,0,3,4,-4,0,3,6,-4,0,3,7,-4,0,3,8,-4,0,3,8,-3,0,3,8,-2,0,3,7,-3,0,3,6,-3,0,3,8,-1,0,3,8,0,0,3,8,1,0,3,8,2,0,3,7,2,0,3,7,3,0,3,6,3,0,3,5,3,0,3,4,3,0,3,3,3,0,3,8,3,0,3,9,3,0,3,9,2,0,3,-2,-3,0,3,-2,-2,0,3,9,0,0,3,9,1,0,3],"Middle":[-2,-7,63,1,-2,-6,2,2,-1,-7,63,1,-1,-6,2,2,0,-7,63,1,0,-6,2,2,1,-7,63,1,1,-6,2,2,2,-7,63,1,2,-6,2,2,3,-7,63,1,3,-6,2,2,4,-7,63,1,4,-6,2,2,5,-7,63,1,5,-6,2,2,5,1,54,1,5,2,1,2,6,-6,54,1,6,-5,1,2,6,1,27,1,6,2,3,2,7,-6,63,1,7,-5,2,2,7,0,27,1,7,1,3,2,8,-6,63,1,8,-5,2,2,9,-2,54,1,9,-1,1,2],"Top":[-4,-8,511,1,-4,-7,511,1,-4,-6,511,1,-4,-5,511,1,-4,-4,511,1,-4,-3,511,1,-4,-2,511,1,-4,-1,511,1,-4,0,511,1,-3,-8,511,1,-3,-7,255,1,-3,-6,219,1,-3,-5,219,1,-3,-4,219,1,-3,-3,219,1,-3,-2,219,1,-3,-1,507,1,-3,0,511,1,-3,1,511,1,-3,2,511,1,-3,3,511,1,-3,4,511,1,-2,-8,511,1,-2,-1,216,1,-2,0,219,1,-2,1,219,1,-2,2,219,1,-2,3,507,1,-2,4,511,1,-1,-8,511,1,-1,3,504,1,-1,4,511,1,0,-8,511,1,0,3,504,1,0,4,511,1,1,-8,511,1,1,3,504,1,1,4,511,1,1,5,511,1,2,-8,511,1,2,3,216,1,2,4,507,1,2,5,511,1,3,-8,511,1,3,4,504,1,3,5,511,1,4,-8,511,1,4,4,504,1,4,5,511,1,5,-8,511,1,5,-2,432,1,5,-1,438,1,5,0,438,1,5,4,504,1,5,5,511,1,6,-8,511,1,6,-7,447,1,6,-2,504,1,6,-1,511,1,6,0,255,1,6,4,504,1,6,5,511,1,7,-8,511,1,7,-7,511,1,7,-2,216,1,7,-1,219,1,7,4,504,1,7,5,511,1,8,-7,511,1,8,4,504,1,8,5,511,1,9,-7,511,1,9,-6,447,1,9,-5,438,1,9,-4,438,1,9,-3,438,1,9,4,504,1,9,5,511,1,10,-7,511,1,10,-6,511,1,10,-5,511,1,10,-4,511,1,10,-3,511,1,10,-2,447,1,10,-1,438,1,10,0,438,1,10,1,438,1,10,2,438,1,10,3,438,1,10,4,510,1,10,5,511,1,11,-3,511,1,11,-2,511,1,11,-1,511,1,11,0,511,1,11,1,511,1,11,2,511,1,11,3,511,1,11,4,511,1,11,5,511,1]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preinstall.json new file mode 100644 index 0000000..8f8adc3 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preinstall.json @@ -0,0 +1 @@ +[{"Name":"Preinstall1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png new file mode 100644 index 0000000..ccdc961 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png.import b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png.import new file mode 100644 index 0000000..e748d06 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preview.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://7m4jc30x73j0" +path="res://.godot/imported/Preview.png-4974b74c6afb3b83df9e34acaa9196c7.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileMaps/Test1/inlet/Start1/Preview.png" +dest_files=["res://.godot/imported/Preview.png-4974b74c6afb3b83df9e34acaa9196c7.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 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/RoomInfo.json new file mode 100644 index 0000000..daafc6c --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/RoomInfo.json @@ -0,0 +1 @@ +{"Position":{"X":-4,"Y":-6},"Size":{"X":11,"Y":10},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":1,"RoomName":"Start1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json new file mode 100644 index 0000000..158475e --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/TileInfo.json @@ -0,0 +1 @@ +{"NavigationVertices":[{"X":74,"Y":34},{"X":-26,"Y":34},{"X":-26,"Y":-42},{"X":74,"Y":-42}],"NavigationPolygon":[[0,1,2,3]],"Floor":[4,-2,0,3,3,-2,0,3,2,-2,0,3,1,-2,0,3,0,-2,0,3,-1,-2,0,3,-2,-2,0,3,-2,-1,0,3,-1,-1,0,3,0,-1,0,3,1,-1,0,3,2,-1,0,3,3,-1,0,3,4,-1,0,3,4,0,0,3,3,0,0,3,2,0,0,3,1,0,0,3,0,0,0,3,-1,0,0,3,-2,0,0,3,-2,1,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,3,1,0,3,4,1,0,3,4,-3,0,3,3,-3,0,3,2,-3,0,3,1,-3,0,3,0,-3,0,3,-1,-3,0,3,-2,-3,0,3],"Middle":[-2,-5,63,1,-2,-4,2,2,-1,-5,63,1,-1,-4,2,2,0,-5,63,1,0,-4,2,2,1,-5,63,1,1,-4,2,2,2,-5,63,1,2,-4,2,2,3,-5,63,1,3,-4,2,2,4,-5,63,1,4,-4,2,2],"Top":[-4,-6,511,1,-4,-5,511,1,-4,-4,511,1,-4,-3,511,1,-4,-2,511,1,-4,-1,511,1,-4,0,511,1,-4,1,511,1,-4,2,511,1,-4,3,511,1,-3,-6,511,1,-3,-5,255,1,-3,-4,219,1,-3,-3,219,1,-3,-2,219,1,-3,-1,219,1,-3,0,219,1,-3,1,219,1,-3,2,507,1,-3,3,511,1,-2,-6,511,1,-2,2,504,1,-2,3,511,1,-1,-6,511,1,-1,2,504,1,-1,3,511,1,0,-6,511,1,0,2,504,1,0,3,511,1,1,-6,511,1,1,2,504,1,1,3,511,1,2,-6,511,1,2,2,504,1,2,3,511,1,3,-6,511,1,3,2,504,1,3,3,511,1,4,-6,511,1,4,2,504,1,4,3,511,1,5,-6,511,1,5,-5,447,1,5,-4,438,1,5,-3,438,1,5,-2,438,1,5,-1,438,1,5,0,438,1,5,1,438,1,5,2,510,1,5,3,511,1,6,-6,511,1,6,-5,511,1,6,-4,511,1,6,-3,511,1,6,-2,511,1,6,-1,511,1,6,0,511,1,6,1,511,1,6,2,511,1,6,3,511,1]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preinstall.json new file mode 100644 index 0000000..638cd69 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preinstall.json @@ -0,0 +1 @@ +[{"Name":"Preinstall1","Weight":100,"Remark":"","WaveList":[[]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png new file mode 100644 index 0000000..e2c6849 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png.import b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png.import new file mode 100644 index 0000000..d152c19 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/Preview.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bjbhmlfjo4fbt" +path="res://.godot/imported/Preview.png-4e96f70cfb64e3f150b72a9f4e2754f6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileMaps/Test1/outlet/End1/Preview.png" +dest_files=["res://.godot/imported/Preview.png-4e96f70cfb64e3f150b72a9f4e2754f6.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 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/RoomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/RoomInfo.json new file mode 100644 index 0000000..c7f87ac --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/RoomInfo.json @@ -0,0 +1 @@ +{"Position":{"X":-4,"Y":-6},"Size":{"X":9,"Y":10},"DoorAreaInfos":[],"GroupName":"Test1","RoomType":2,"RoomName":"End1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/TileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/TileInfo.json new file mode 100644 index 0000000..3d8ad82 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/outlet/End1/TileInfo.json @@ -0,0 +1 @@ +{"NavigationVertices":[{"X":42,"Y":34},{"X":-26,"Y":34},{"X":-26,"Y":-42},{"X":42,"Y":-42}],"NavigationPolygon":[[0,1,2,3]],"Floor":[-2,-1,0,3,-2,-2,0,3,-1,-2,0,3,0,-2,0,3,1,-2,0,3,1,-1,0,3,2,-1,0,3,0,-1,0,3,-1,-1,0,3,-2,0,0,3,-2,1,0,3,-1,1,0,3,0,1,0,3,1,1,0,3,2,1,0,3,2,0,0,3,1,0,0,3,0,0,0,3,-1,0,0,3,2,-2,0,3,2,-3,0,3,1,-3,0,3,0,-3,0,3,-1,-3,0,3,-2,-3,0,3],"Middle":[-2,-5,63,1,-2,-4,2,2,-1,-5,63,1,-1,-4,2,2,0,-5,63,1,0,-4,2,2,1,-5,63,1,1,-4,2,2,2,-5,63,1,2,-4,2,2],"Top":[-4,-6,511,1,-4,-5,511,1,-4,-4,511,1,-4,-3,511,1,-4,-2,511,1,-4,-1,511,1,-4,0,511,1,-4,1,511,1,-4,2,511,1,-4,3,511,1,-3,-6,511,1,-3,-5,255,1,-3,-4,219,1,-3,-3,219,1,-3,-2,219,1,-3,-1,219,1,-3,0,219,1,-3,1,219,1,-3,2,507,1,-3,3,511,1,-2,-6,511,1,-2,2,504,1,-2,3,511,1,-1,-6,511,1,-1,2,504,1,-1,3,511,1,0,-6,511,1,0,2,504,1,0,3,511,1,1,-6,511,1,1,2,504,1,1,3,511,1,2,-6,511,1,2,2,504,1,2,3,511,1,3,-6,511,1,3,-5,447,1,3,-4,438,1,3,-3,438,1,3,-2,438,1,3,-1,438,1,3,0,438,1,3,1,438,1,3,2,510,1,3,3,511,1,4,-6,511,1,4,-5,511,1,4,-4,511,1,4,-3,511,1,4,-2,511,1,4,-1,511,1,4,0,511,1,4,1,511,1,4,2,511,1,4,3,511,1]} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet1/Main.png b/DungeonShooting_Godot/resource/map/tileSet/TileSet1/Main.png index cb64efb..c3cbdb1 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSet1/Main.png +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet1/Main.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png new file mode 100644 index 0000000..d74eba2 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png.import b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png.import new file mode 100644 index 0000000..be7dd76 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Main.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c6pesrr162s6" +path="res://.godot/imported/Main.png-d5a6dac6cf1a2b2af633c597ddadfe73.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileSet/TileSet2/Main.png" +dest_files=["res://.godot/imported/Main.png-d5a6dac6cf1a2b2af633c597ddadfe73.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 diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png new file mode 100644 index 0000000..d74eba2 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png.import b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png.import new file mode 100644 index 0000000..2dd9ddc --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dslcjy284qx53" +path="res://.godot/imported/Test2.png-427a8c43a36ea928d410624045881fbb.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/map/tileSet/TileSet2/Test2.png" +dest_files=["res://.godot/imported/Test2.png-427a8c43a36ea928d410624045881fbb.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 diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json new file mode 100644 index 0000000..a7c8f84 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json @@ -0,0 +1,345 @@ +{ + "Name": "TileSet2", + "Sources": [ + { + "Name": "Main", + "SourcePath": "resource/map/tileSet/TileSet2/Main.png", + "Terrain": { + "F": {}, + "M": { + "1": [ + 16, + 32 + ], + "2": [ + 32, + 32 + ] + }, + "T": { + "432": [ + 16, + 32 + ] + } + }, + "Combination": [ + { + "Id": "638404496948408912", + "Name": "\u7EC4\u5408", + "Cells": [ + { + "X": 160, + "Y": 128 + }, + { + "X": 176, + "Y": 128 + }, + { + "X": 192, + "Y": 128 + }, + { + "X": 208, + "Y": 128 + }, + { + "X": 224, + "Y": 128 + }, + { + "X": 240, + "Y": 128 + }, + { + "X": 240, + "Y": 144 + }, + { + "X": 224, + "Y": 144 + }, + { + "X": 208, + "Y": 144 + }, + { + "X": 192, + "Y": 144 + }, + { + "X": 176, + "Y": 144 + }, + { + "X": 160, + "Y": 144 + }, + { + "X": 160, + "Y": 128 + }, + { + "X": 176, + "Y": 128 + }, + { + "X": 192, + "Y": 128 + }, + { + "X": 208, + "Y": 128 + }, + { + "X": 224, + "Y": 128 + }, + { + "X": 240, + "Y": 128 + }, + { + "X": 240, + "Y": 144 + }, + { + "X": 224, + "Y": 144 + }, + { + "X": 208, + "Y": 144 + }, + { + "X": 192, + "Y": 144 + }, + { + "X": 176, + "Y": 144 + }, + { + "X": 160, + "Y": 144 + } + ], + "Positions": [ + { + "X": 0, + "Y": 0 + }, + { + "X": 16, + "Y": 0 + }, + { + "X": 32, + "Y": 0 + }, + { + "X": 48, + "Y": 0 + }, + { + "X": 64, + "Y": 0 + }, + { + "X": 80, + "Y": 0 + }, + { + "X": 80, + "Y": 16 + }, + { + "X": 64, + "Y": 16 + }, + { + "X": 48, + "Y": 16 + }, + { + "X": 32, + "Y": 16 + }, + { + "X": 16, + "Y": 16 + }, + { + "X": 0, + "Y": 16 + }, + { + "X": 0, + "Y": 32 + }, + { + "X": 16, + "Y": 32 + }, + { + "X": 32, + "Y": 32 + }, + { + "X": 48, + "Y": 32 + }, + { + "X": 64, + "Y": 32 + }, + { + "X": 80, + "Y": 32 + }, + { + "X": 80, + "Y": 48 + }, + { + "X": 64, + "Y": 48 + }, + { + "X": 48, + "Y": 48 + }, + { + "X": 32, + "Y": 48 + }, + { + "X": 16, + "Y": 48 + }, + { + "X": 0, + "Y": 48 + } + ] + } + ] + }, + { + "Name": "Test2", + "SourcePath": "resource/map/tileSet/TileSet2/Test2.png", + "Terrain": { + "F": {}, + "M": {}, + "T": {} + }, + "Combination": [ + { + "Id": "638404127381228219", + "Name": "\u67F1\u5B50", + "Cells": [ + { + "X": 224, + "Y": 64 + }, + { + "X": 224, + "Y": 80 + }, + { + "X": 224, + "Y": 96 + }, + { + "X": 224, + "Y": 64 + }, + { + "X": 224, + "Y": 80 + }, + { + "X": 224, + "Y": 96 + }, + { + "X": 224, + "Y": 64 + }, + { + "X": 224, + "Y": 80 + }, + { + "X": 224, + "Y": 96 + }, + { + "X": 224, + "Y": 64 + }, + { + "X": 224, + "Y": 80 + }, + { + "X": 224, + "Y": 96 + } + ], + "Positions": [ + { + "X": 48, + "Y": 0 + }, + { + "X": 48, + "Y": 16 + }, + { + "X": 48, + "Y": 32 + }, + { + "X": 32, + "Y": 0 + }, + { + "X": 32, + "Y": 16 + }, + { + "X": 32, + "Y": 32 + }, + { + "X": 16, + "Y": 0 + }, + { + "X": 16, + "Y": 16 + }, + { + "X": 16, + "Y": 32 + }, + { + "X": 0, + "Y": 0 + }, + { + "X": 0, + "Y": 16 + }, + { + "X": 0, + "Y": 32 + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json b/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json index 052c022..d7d71d6 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSetConfig.json @@ -3,5 +3,10 @@ "ErrorType": 0, "Path": "resource/map/tileSet/TileSet1", "Remark": "" + }, + "TileSet2": { + "ErrorType": 0, + "Path": "resource/map/tileSet/TileSet2", + "Remark": "" } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 9d39372..6ef9196 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -85,7 +85,7 @@ var y = int.MaxValue; var x2 = int.MinValue; var y2 = int.MinValue; - for (var i = 0; i < tileInfo.Floor.Count; i += 5) + for (var i = 0; i < tileInfo.Floor.Count; i += 4) { var posX = tileInfo.Floor[i]; var posY = tileInfo.Floor[i + 1]; @@ -98,7 +98,7 @@ var image = Image.Create(x2 - x + 3, y2 - y + 3, false, Image.Format.Rgba8); //image.Fill(Colors.Green); //填充像素点 - for (var i = 0; i < tileInfo.Floor.Count; i += 5) + for (var i = 0; i < tileInfo.Floor.Count; i += 4) { var posX = tileInfo.Floor[i] - x + 1; var posY = tileInfo.Floor[i + 1] - y + 1; @@ -109,38 +109,46 @@ roomInfo.PreviewTexture = imageTexture; //---------------------- 填充tile操作 ---------------------- + var terrainInfo = config.TerrainInfo; + //底层 - for (var i = 0; i < tileInfo.Floor.Count; i += 5) + for (var i = 0; i < tileInfo.Floor.Count; i += 4) { var posX = tileInfo.Floor[i]; var posY = tileInfo.Floor[i + 1]; - var sourceId = tileInfo.Floor[i + 2]; - var atlasCoordsX = tileInfo.Floor[i + 3]; - var atlasCoordsY = tileInfo.Floor[i + 4]; var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - _tileRoot.SetCell(GameConfig.FloorMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + var bit = (uint)tileInfo.Floor[i + 2]; + var type = (byte)tileInfo.Floor[i + 3]; + var index = terrainInfo.TerrainBitToIndex(bit, type); + var terrainCell = terrainInfo.GetTerrainCell(index, type); + var atlasCoords = terrainInfo.GetPosition(terrainCell); + _tileRoot.SetCell(GameConfig.FloorMapLayer, pos, config.SourceId, atlasCoords); } //中层 - for (var i = 0; i < tileInfo.Middle.Count; i += 5) + for (var i = 0; i < tileInfo.Middle.Count; i += 4) { var posX = tileInfo.Middle[i]; var posY = tileInfo.Middle[i + 1]; - var sourceId = tileInfo.Middle[i + 2]; - var atlasCoordsX = tileInfo.Middle[i + 3]; - var atlasCoordsY = tileInfo.Middle[i + 4]; var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - _tileRoot.SetCell(GameConfig.MiddleMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + var bit = (uint)tileInfo.Middle[i + 2]; + var type = (byte)tileInfo.Middle[i + 3]; + var index = terrainInfo.TerrainBitToIndex(bit, type); + var terrainCell = terrainInfo.GetTerrainCell(index, type); + var atlasCoords = terrainInfo.GetPosition(terrainCell); + _tileRoot.SetCell(GameConfig.MiddleMapLayer, pos, config.SourceId, atlasCoords); } //顶层 - for (var i = 0; i < tileInfo.Top.Count; i += 5) + for (var i = 0; i < tileInfo.Top.Count; i += 4) { var posX = tileInfo.Top[i]; var posY = tileInfo.Top[i + 1]; - var sourceId = tileInfo.Top[i + 2]; - var atlasCoordsX = tileInfo.Top[i + 3]; - var atlasCoordsY = tileInfo.Top[i + 4]; var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); - _tileRoot.SetCell(GameConfig.TopMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); + var bit = (uint)tileInfo.Top[i + 2]; + var type = (byte)tileInfo.Top[i + 3]; + var index = terrainInfo.TerrainBitToIndex(bit, type); + var terrainCell = terrainInfo.GetTerrainCell(index, type); + var atlasCoords = terrainInfo.GetPosition(terrainCell); + _tileRoot.SetCell(GameConfig.TopMapLayer, pos, config.SourceId, atlasCoords); } //寻找可用传送点 diff --git a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs index c341827..db987d8 100644 --- a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs +++ b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs @@ -286,6 +286,20 @@ callback(uiCell); } } + + /// + /// 遍历所有 Cell, 回调函数返回 false 跳出循环 + /// + public void ForEach(Func, bool> callback) + { + foreach (var uiCell in _cellList) + { + if (!callback(uiCell)) + { + return; + } + } + } /// /// 设置当前网格组件中的所有 Cell 数据, 性能较低 diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index e748120..21cc943 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -104,7 +104,7 @@ Enemy.InitEnemyAttribute(); DungeonConfig = new DungeonConfig(); - DungeonConfig.GroupName = "TestGroup2"; + DungeonConfig.GroupName = "Test1"; DungeonConfig.RoomCount = 20; } diff --git a/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs b/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs index 45d75c1..44dbb5c 100644 --- a/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs +++ b/DungeonShooting_Godot/src/game/common/ui/EditorGridBg.cs @@ -19,6 +19,7 @@ public T UiNode { get; private set; } private ShaderMaterial _gridMaterial; + private bool _dragMoveFlag = false; /// /// 初始化节点数据 @@ -75,10 +76,24 @@ //拖拽回调 private void OnDrag(DragState state, Vector2 pos) { - if (state == DragState.DragMove) + if (state == DragState.DragStart) { - ContainerRoot.Position += pos; - RefreshGridTrans(); + if (this.IsMouseInRect()) + { + _dragMoveFlag = true; + } + } + else if (state == DragState.DragMove) + { + if (_dragMoveFlag) + { + ContainerRoot.Position += pos; + RefreshGridTrans(); + } + } + else + { + _dragMoveFlag = false; } } diff --git a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs index 844db17..599edec 100644 --- a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs +++ b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs @@ -121,19 +121,19 @@ int[] data; if (terrainInfo.M.TryGetValue(0, out data)) { - Wall_Vertical_Single = new TileCellData(sourceId, terrainInfo.GetPosition(data), TerrainPeering.None, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Single = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); } if (terrainInfo.M.TryGetValue(1, out data)) { - Wall_Vertical_Left= new TileCellData(sourceId, terrainInfo.GetPosition(data), TerrainPeering.None, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Left= new TileCellData(sourceId, terrainInfo.GetPosition(data), 1, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); } if (terrainInfo.M.TryGetValue(2, out data)) { - Wall_Vertical_Center= new TileCellData(sourceId, terrainInfo.GetPosition(data), TerrainPeering.None, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Center= new TileCellData(sourceId, terrainInfo.GetPosition(data), 2, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); } if (terrainInfo.M.TryGetValue(3, out data)) { - Wall_Vertical_Right= new TileCellData(sourceId, terrainInfo.GetPosition(data), TerrainPeering.None, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); + Wall_Vertical_Right= new TileCellData(sourceId, terrainInfo.GetPosition(data), 3, TileSetTerrainInfo.MiddleLayerType, GameConfig.MiddleMapLayer); } } @@ -141,7 +141,7 @@ { if (terrainInfo.F.TryGetValue(0, out var data)) { - Floor = new TileCellData(sourceId, terrainInfo.GetPosition(data), TerrainPeering.None, TileSetTerrainInfo.FloorLayerType, GameConfig.FloorMapLayer); + Floor = new TileCellData(sourceId, terrainInfo.GetPosition(data), 0, TileSetTerrainInfo.FloorLayerType, GameConfig.FloorMapLayer); } } diff --git a/DungeonShooting_Godot/src/game/room/World.cs b/DungeonShooting_Godot/src/game/room/World.cs index d6db819..75f8634 100644 --- a/DungeonShooting_Godot/src/game/room/World.cs +++ b/DungeonShooting_Godot/src/game/room/World.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using Godot; /// @@ -73,10 +74,7 @@ Color = Colors.Black; //临时处理, 加载TileSet - var tileSet = ResourceManager.Load(ResourcePath.resource_tileSet_map2_TileSet2_tres); - //var tileSet = ResourceManager.Load(ResourcePath.resource_tileSet_map1_TileSet1_tres); - //var tileSetAtlasSource = (TileSetAtlasSource)tileSet.GetSource(0); - //tileSetAtlasSource.Texture = ImageTexture.CreateFromImage(Image.LoadFromFile("resource/tileSprite/map1/16x16 dungeon ii wall reconfig v04 spritesheet.png")); + var tileSet = GameApplication.Instance.TileSetConfig.First().Value.GetTileSet(); TileRoot.TileSet = tileSet; //TileRoot.YSortEnabled = false; } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs index 96d3367..5695611 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs @@ -241,7 +241,12 @@ { var optionButton = S_OptionButton.Instance; var selectIndex = optionButton.Selected; - if (selectIndex >= 0) + if (selectIndex == 0) + { + EditorWindowManager.ShowTips("警告", "不允许删除 Main Source!"); + return; + } + else if (selectIndex > 0) { EditorWindowManager.ShowConfirm("提示", "是否需要删除该资源!", v => { diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs index 75a55a4..535bda5 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs @@ -1,5 +1,4 @@ using System.IO; -using System.Text.Json; using Godot; namespace UI.TileSetEditorProject; @@ -83,6 +82,12 @@ var tileSetInfo = new TileSetInfo(); tileSetInfo.InitData(); tileSetInfo.Name = name; + //默认创建一个Main Source, 该Source不可删除 + var tileSetSourceInfo = new TileSetSourceInfo(); + tileSetSourceInfo.InitData(); + tileSetSourceInfo.Name = "Main"; + tileSetInfo.Sources.Add(tileSetSourceInfo); + split.SetTileSetInfo(tileSetInfo); GameApplication.Instance.TileSetConfig.Add(name, split); //保存TileSetInfo diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs index cc586b7..0f40a5d 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs @@ -18,6 +18,19 @@ } private VSplitContainer _L_VSplitContainer; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.DragSprite + /// + public DragSprite L_DragSprite + { + get + { + if (_L_DragSprite == null) _L_DragSprite = new DragSprite((TileSetEditorTerrainPanel)this, GetNode("DragSprite")); + return _L_DragSprite; + } + } + private DragSprite _L_DragSprite; + public TileSetEditorTerrain() : base(nameof(TileSetEditorTerrain)) { @@ -40,9 +53,9 @@ } /// - /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell /// - public class RightCell : UiNode + public class RightCell : UiNode { /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.CellTexture @@ -57,8 +70,8 @@ } private CellTexture _L_CellTexture; - public RightCell(TileSetEditorTerrainPanel uiPanel, UI.TileSetEditorTerrain.TerrainCellDropHandler node) : base(uiPanel, node) { } - public override RightCell Clone() => new (UiPanel, (UI.TileSetEditorTerrain.TerrainCellDropHandler)Instance.Duplicate()); + public RightCell(TileSetEditorTerrainPanel uiPanel, Godot.Control node) : base(uiPanel, node) { } + public override RightCell Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); } /// @@ -67,13 +80,13 @@ public class CellRoot : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.RightCell + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.RightCell /// public RightCell L_RightCell { get { - if (_L_RightCell == null) _L_RightCell = new RightCell(UiPanel, Instance.GetNode("RightCell")); + if (_L_RightCell == null) _L_RightCell = new RightCell(UiPanel, Instance.GetNode("RightCell")); return _L_RightCell; } } @@ -370,12 +383,12 @@ } /// - /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.CellRoot.BottomCell + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.CellRoot.BottomCell /// - public class BottomCell : UiNode + public class BottomCell : UiNode { - public BottomCell(TileSetEditorTerrainPanel uiPanel, UI.TileSetEditorTerrain.TerrainCellDragHandler node) : base(uiPanel, node) { } - public override BottomCell Clone() => new (UiPanel, (UI.TileSetEditorTerrain.TerrainCellDragHandler)Instance.Duplicate()); + public BottomCell(TileSetEditorTerrainPanel uiPanel, Godot.Control node) : base(uiPanel, node) { } + public override BottomCell Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); } /// @@ -384,13 +397,13 @@ public class CellRoot_1 : UiNode { /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.BottomCell + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.BottomCell /// public BottomCell L_BottomCell { get { - if (_L_BottomCell == null) _L_BottomCell = new BottomCell(UiPanel, Instance.GetNode("BottomCell")); + if (_L_BottomCell == null) _L_BottomCell = new BottomCell(UiPanel, Instance.GetNode("BottomCell")); return _L_BottomCell; } } @@ -589,6 +602,15 @@ public override VSplitContainer Clone() => new (UiPanel, (Godot.VSplitContainer)Instance.Duplicate()); } + /// + /// 类型: , 路径: TileSetEditorTerrain.DragSprite + /// + public class DragSprite : UiNode + { + public DragSprite(TileSetEditorTerrainPanel uiPanel, Godot.Sprite2D node) : base(uiPanel, node) { } + public override DragSprite Clone() => new (UiPanel, (Godot.Sprite2D)Instance.Duplicate()); + } + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell.CellTexture @@ -596,7 +618,7 @@ public CellTexture S_CellTexture => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_CellRoot.L_RightCell.L_CellTexture; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell /// public RightCell S_RightCell => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_CellRoot.L_RightCell; @@ -636,7 +658,7 @@ public PanelTop S_PanelTop => L_VSplitContainer.L_PanelTop; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.CellRoot.BottomCell + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelBottom.MarginContainer.BottomBg.TileTexture.CellRoot.BottomCell /// public BottomCell S_BottomCell => L_VSplitContainer.L_PanelBottom.L_MarginContainer.L_BottomBg.L_TileTexture.L_CellRoot.L_BottomCell; @@ -665,4 +687,9 @@ /// public VSplitContainer S_VSplitContainer => L_VSplitContainer; + /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.DragSprite + /// + public DragSprite S_DragSprite => L_DragSprite; + } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs index 2c95197..20f313c 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs @@ -11,9 +11,9 @@ public TileSetEditorPanel EditorPanel; /// - /// 是否正在拖拽图块 + /// 正在拖拽的图块 /// - public bool IsDraggingCell { get; set; } + public MaskCell DraggingCell { get; set; } private UiGrid _topGrid1; private UiGrid _topGrid2; @@ -23,6 +23,7 @@ public override void OnCreateUi() { EditorPanel = (TileSetEditorPanel)ParentUi; + S_DragSprite.Instance.Visible = false; //改变选中的TileSet资源 AddEventListener(EventEnum.OnSelectTileSetSource, OnSelectTileSetSource); @@ -49,7 +50,7 @@ public override void Process(float delta) { - S_MaskBrush.Instance.Visible = !IsDraggingCell; + S_MaskBrush.Instance.Visible = DraggingCell == null; } private UiGrid InitTopGrid(Control texture, Vector2I size, byte type) @@ -75,9 +76,9 @@ private void OnSelectTileSetSource(object obj) { //先清除所有绑定的Terrain - _topGrid1.ForEach(cell => cell.CellNode.Instance.ClearCell()); - _topGrid2.ForEach(cell => cell.CellNode.Instance.ClearCell()); - _topGrid3.ForEach(cell => cell.CellNode.Instance.ClearCell()); + _topGrid1.ForEach(cell => ((TerrainCell)cell).ClearCell()); + _topGrid2.ForEach(cell => ((TerrainCell)cell).ClearCell()); + _topGrid3.ForEach(cell => ((TerrainCell)cell).ClearCell()); //再加载Terrain if (obj != null) @@ -88,7 +89,7 @@ var ints = terrain.GetTerrainCell( cell.Index, cell.Data); if (ints != null) { - cell.CellNode.Instance.SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); + ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); } }); _topGrid2.ForEach(cell => @@ -96,7 +97,7 @@ var ints = terrain.GetTerrainCell(cell.Index, cell.Data); if (ints != null) { - cell.CellNode.Instance.SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); + ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); } }); _topGrid3.ForEach(cell => @@ -104,12 +105,40 @@ var ints = terrain.GetTerrainCell( cell.Index, cell.Data); if (ints != null) { - cell.CellNode.Instance.SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); + ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); } }); } } + /// + /// 放置地形Cell纹理 + /// + public void OnDropCell(MaskCell maskCell) + { + var flag = true; + _topGrid1.ForEach((cell) => + { + flag = !((TerrainCell)cell).OnDropCell(maskCell); + return flag; + }); + if (flag) + { + _topGrid2.ForEach((cell) => + { + flag = !((TerrainCell)cell).OnDropCell(maskCell); + return flag; + }); + } + if (flag) + { + _topGrid3.ForEach((cell) => + { + return ((TerrainCell)cell).OnDropCell(maskCell); + }); + } + } + //改变TileSet纹理 private void OnSetTileTexture(object arg) { diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs index 39a52f2..4df02b3 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs @@ -4,23 +4,77 @@ public class MaskCell : UiCell { + private TextureRect _textureRect; + private Texture2D _texture; + private TileSetEditorTerrainPanel _panel; + private bool _dragMoveFlag = false; + public override void OnInit() { - CellNode.Instance.Init(this); + _panel = CellNode.UiPanel; + _textureRect = _panel.S_BottomBg.L_TileTexture.Instance; + _texture = _textureRect.Texture; + CellNode.Instance.Draw += Draw; + CellNode.Instance.AddDragListener(OnDrag); } - public override void OnSetData(Rect2I data) + public override void Process(float delta) { - CellNode.Instance.SetRect(data); + CellNode.Instance.QueueRedraw(); } - public override void OnSelect() + //拖拽操作 + private void OnDrag(DragState state, Vector2 delta) { - CellNode.Instance.DragOutline = true; + var sprite = _panel.S_DragSprite.Instance; + if (state == DragState.DragStart) //拖拽开始 + { + //这里要判断一下是否在BottomBg区域内 + if (CellNode.UiPanel.S_BottomBg.Instance.IsMouseInRect()) + { + _panel.DraggingCell = this; + Grid.SelectIndex = Index; + _dragMoveFlag = false; + } + } + else if (state == DragState.DragEnd) //拖拽结束 + { + if (_panel.DraggingCell == this) + { + _panel.DraggingCell = null; + sprite.Visible = false; + _dragMoveFlag = false; + + if (_panel.S_TopBg.Instance.IsMouseInRect()) //找到放置的Cell + { + _panel.OnDropCell(this); + } + } + } + else if (_panel.DraggingCell == this) //拖拽移动 + { + if (!_dragMoveFlag) + { + _dragMoveFlag = true; + sprite.Texture = _texture; + sprite.RegionRect = Data; + sprite.Scale = _panel.S_TopBg.L_TerrainRoot.Instance.Scale; + sprite.Visible = true; + sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + } + sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + } } - public override void OnUnSelect() + private void Draw() { - CellNode.Instance.DragOutline = false; + if (Grid.SelectIndex == Index) + { + //选中时绘制轮廓 + CellNode.Instance.DrawRect( + new Rect2(Vector2.Zero, CellNode.Instance.Size), + new Color(0, 1, 1), false, 2f / _textureRect.Scale.X + ); + } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TerrainCellDragHandler.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TerrainCellDragHandler.cs deleted file mode 100644 index acb84b2..0000000 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TerrainCellDragHandler.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Godot; - -namespace UI.TileSetEditorTerrain; - -public partial class TerrainCellDragHandler : TextureButton -{ - /// - /// 是否绘制轮廓 - /// - public bool DragOutline { get; set; } = false; - - private TextureRect _textureRect; - private Texture2D _texture; - private Rect2I _rect2I; - private MaskCell _maskCell; - private TileSetEditorTerrainPanel _panel; - - public void Init(MaskCell maskCell) - { - _maskCell = maskCell; - _panel = maskCell.CellNode.UiPanel; - _textureRect = _panel.S_BottomBg.L_TileTexture.Instance; - _texture = _textureRect.Texture; - } - - public void SetRect(Rect2I rect) - { - _rect2I = rect; - } - - public override void _Process(double delta) - { - QueueRedraw(); - if (_maskCell.Grid.SelectIndex == _maskCell.Index && _panel.IsDraggingCell) - { - if (!Input.IsActionPressed(InputAction.MouseLeft)) - { - _panel.IsDraggingCell = false; - } - } - } - - public override Variant _GetDragData(Vector2 atPosition) - { - _panel.IsDraggingCell = true; - _maskCell.Grid.SelectIndex = _maskCell.Index; - var sprite = new Sprite2D(); - sprite.Texture = _texture; - sprite.RegionEnabled = true; - sprite.RegionRect = _rect2I; - var control = new Control(); - control.AddChild(sprite); - control.ZIndex = 10; - control.Scale = _panel.S_TopBg.L_TerrainRoot.Instance.Scale; - SetDragPreview(control); - return _rect2I; - } - - public override void _Draw() - { - if (DragOutline) - { - //选中时绘制轮廓 - DrawRect( - new Rect2(Vector2.Zero, Size), - new Color(0, 1, 1), false, 2f / _textureRect.Scale.X - ); - } - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs index f73831e..00c9deb 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs @@ -4,8 +4,91 @@ public class TerrainCell : UiCell { + /// + /// 是否放置了图块 + /// + public bool IsPutDownTexture { get; private set; } + + /// + /// 图块在 Source 中的位置, 单位: 像素 + /// + public Vector2I TextureCell { get; private set; } + + private TileSetEditorTerrainPanel _panel; + public override void OnInit() { - CellNode.Instance.Init(this); + _panel = CellNode.UiPanel; + CellNode.Instance.GuiInput += OnGuiInput; + } + + public bool OnDropCell(MaskCell maskCell) + { + if (CellNode.Instance.IsMouseInRect()) + { + OnDropData(maskCell); + return true; + } + + return false; + } + + private void OnGuiInput(InputEvent @event) + { + if (@event is InputEventMouseButton mouseEvent) + { + if (mouseEvent.ButtonIndex == MouseButton.Right && mouseEvent.Pressed) //右键擦除图块 + { + CellNode.Instance.AcceptEvent(); + var flag = IsPutDownTexture; + ClearCell(); + if (flag) + { + SetTerrainBitData(null); + } + } + } + } + + /// + /// 设置选择的Cell + /// + public void SetCell(Rect2I rect) + { + TextureCell = rect.Position; + var sprite2D = CellNode.L_CellTexture.Instance; + sprite2D.Texture = _panel.EditorPanel.Texture; + sprite2D.RegionEnabled = true; + sprite2D.RegionRect = rect; + IsPutDownTexture = true; + } + + /// + /// 清除选中的cell + /// + public void ClearCell() + { + CellNode.L_CellTexture.Instance.Texture = null; + IsPutDownTexture = false; + } + + private void OnDropData(MaskCell maskCell) + { + SetCell(maskCell.Data); + SetTerrainBitData(new []{ TextureCell.X, TextureCell.Y }); + } + + private void SetTerrainBitData(int[] cellData) + { + if (cellData == null) + { + _panel.EditorPanel.TileSetSourceInfo.Terrain.RemoveTerrainCell(Index, Data); + } + else + { + _panel.EditorPanel.TileSetSourceInfo.Terrain.SetTerrainCell(Index, Data, cellData); + } + + EventManager.EmitEvent(EventEnum.OnTileSetDirty); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs deleted file mode 100644 index 2f7a0fc..0000000 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs +++ /dev/null @@ -1,88 +0,0 @@ -using Godot; - -namespace UI.TileSetEditorTerrain; - -public partial class TerrainCellDropHandler : Control -{ - /// - /// 是否放置了图块 - /// - public bool IsPutDownTexture { get; private set; } - - /// - /// 图块在 Source 中的位置, 单位: 像素 - /// - public Vector2I TextureCell { get; private set; } - - private TerrainCell _cell; - private TileSetEditorTerrainPanel _panel; - - public void Init(TerrainCell cell) - { - _cell = cell; - _panel = cell.CellNode.UiPanel; - } - - public override bool _CanDropData(Vector2 atPosition, Variant data) - { - return data.VariantType == Variant.Type.Rect2I; - } - - public override void _DropData(Vector2 atPosition, Variant data) - { - var rect = data.AsRect2I(); - SetCell(rect); - SetTerrainBitData(new []{ TextureCell.X, TextureCell.Y }); - } - - public override void _GuiInput(InputEvent @event) - { - //右键擦除图块 - if (@event is InputEventMouseButton mouseEvent && mouseEvent.ButtonIndex == MouseButton.Right && mouseEvent.Pressed) - { - AcceptEvent(); - var flag = IsPutDownTexture; - ClearCell(); - if (flag) - { - SetTerrainBitData(null); - } - } - } - - /// - /// 设置选择的Cell - /// - public void SetCell(Rect2I rect) - { - TextureCell = rect.Position; - var sprite2D = _cell.CellNode.L_CellTexture.Instance; - sprite2D.Texture = _panel.EditorPanel.Texture; - sprite2D.RegionEnabled = true; - sprite2D.RegionRect = rect; - IsPutDownTexture = true; - } - - /// - /// 清除选中的cell - /// - public void ClearCell() - { - _cell.CellNode.L_CellTexture.Instance.Texture = null; - IsPutDownTexture = false; - } - - private void SetTerrainBitData(int[] cellData) - { - if (cellData == null) - { - _panel.EditorPanel.TileSetSourceInfo.Terrain.RemoveTerrainCell(_cell.Index, _cell.Data); - } - else - { - _panel.EditorPanel.TileSetSourceInfo.Terrain.SetTerrainCell(_cell.Index, _cell.Data, cellData); - } - - EventManager.EmitEvent(EventEnum.OnTileSetDirty); - } -} \ No newline at end of file