diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn index 1f9085a..e4b32fa 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://dfqb73y4br8yd"] +[gd_scene load_steps=11 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"] @@ -6,6 +6,7 @@ [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://dyshwhf3101em" path="res://resource/sprite/map/TerrainMask4.png" id="6_vbhca"] [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"] @@ -87,6 +88,20 @@ z_index = -1 centered = false +[node name="ColorRect" type="ColorRect" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot/CellRoot/RightCell"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 3.0 +offset_top = 3.0 +offset_right = -4.0 +offset_bottom = -4.0 +grow_horizontal = 2 +grow_vertical = 2 +mouse_filter = 2 +color = Color(0, 0, 0, 0.6) + [node name="TerrainTexture1" type="TextureRect" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot"] self_modulate = Color(1, 1, 1, 0.27451) custom_minimum_size = Vector2(192, 64) @@ -141,6 +156,24 @@ scale = Vector2(0.25, 0.25) text = "地板" +[node name="TerrainTexture4" type="TextureRect" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot"] +visible = false +self_modulate = Color(1, 1, 1, 0.27451) +custom_minimum_size = Vector2(80, 48) +layout_mode = 1 +offset_right = 80.0 +offset_bottom = 48.0 +mouse_filter = 2 +texture = ExtResource("6_vbhca") + +[node name="Label" type="Label" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot/TerrainTexture4"] +layout_mode = 0 +offset_top = -10.0 +offset_right = 136.0 +offset_bottom = 30.0 +scale = Vector2(0.25, 0.25) +text = "地形" + [node name="Brush" type="Control" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot"] layout_mode = 1 anchors_preset = 15 @@ -176,6 +209,23 @@ ignore_texture_size = true stretch_mode = 5 +[node name="TerrainTypeButton" type="OptionButton" parent="VSplitContainer/PanelTop/MarginContainer/TopBg"] +layout_mode = 1 +anchors_preset = 1 +anchor_left = 1.0 +anchor_right = 1.0 +offset_left = -330.0 +offset_top = 14.0 +offset_right = -94.0 +offset_bottom = 69.0 +grow_horizontal = 0 +item_count = 2 +selected = 0 +popup/item_0/text = "47格(3*3)" +popup/item_0/id = 0 +popup/item_1/text = "13格(2*2))" +popup/item_1/id = 1 + [node name="PanelBottom" type="Panel" parent="VSplitContainer"] layout_mode = 2 size_flags_horizontal = 3 diff --git a/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png b/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png new file mode 100644 index 0000000..8416b87 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png.import b/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png.import new file mode 100644 index 0000000..4c96cd0 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/map/TerrainMask4.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dyshwhf3101em" +path="res://.godot/imported/TerrainMask4.png-946931709433ef3d5ae9865b1065e17f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/map/TerrainMask4.png" +dest_files=["res://.godot/imported/TerrainMask4.png-946931709433ef3d5ae9865b1065e17f.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/scene/test/TestTerrain2x2.tscn b/DungeonShooting_Godot/scene/test/TestTerrain2x2.tscn new file mode 100644 index 0000000..2619f48 --- /dev/null +++ b/DungeonShooting_Godot/scene/test/TestTerrain2x2.tscn @@ -0,0 +1,126 @@ +[gd_scene load_steps=4 format=3 uid="uid://bwxo7kc5ybrou"] + +[ext_resource type="Texture2D" uid="uid://bcoae24vin57c" path="res://resource/tileSprite/map2/Dungeon Tileset.png" id="1_ivn6d"] + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_23gwl"] +texture = ExtResource("1_ivn6d") +0:0/0 = 0 +1:0/0 = 0 +2:0/0 = 0 +3:0/0 = 0 +4:0/0 = 0 +5:0/0 = 0 +6:0/0 = 0 +7:0/0 = 0 +8:0/0 = 0 +8:0/0/terrain_set = 0 +8:0/0/terrain = 0 +8:0/0/terrains_peering_bit/bottom_right_corner = 0 +9:0/0 = 0 +10:0/0 = 0 +10:0/0/terrain_set = 0 +10:0/0/terrain = 0 +10:0/0/terrains_peering_bit/bottom_right_corner = 0 +10:0/0/terrains_peering_bit/bottom_left_corner = 0 +11:0/0 = 0 +11:0/0/terrain_set = 0 +11:0/0/terrain = 0 +11:0/0/terrains_peering_bit/bottom_left_corner = 0 +0:1/0 = 0 +1:1/0 = 0 +2:1/0 = 0 +3:1/0 = 0 +4:1/0 = 0 +5:1/0 = 0 +5:1/0/terrain_set = 0 +5:1/0/terrain = 0 +5:1/0/terrains_peering_bit/bottom_right_corner = 0 +5:1/0/terrains_peering_bit/bottom_left_corner = 0 +5:1/0/terrains_peering_bit/top_right_corner = 0 +6:1/0 = 0 +6:1/0/terrain_set = 0 +6:1/0/terrain = 0 +6:1/0/terrains_peering_bit/bottom_right_corner = 0 +6:1/0/terrains_peering_bit/bottom_left_corner = 0 +6:1/0/terrains_peering_bit/top_left_corner = 0 +7:1/0 = 0 +8:1/0 = 0 +8:1/0/terrain_set = 0 +8:1/0/terrain = 0 +8:1/0/terrains_peering_bit/bottom_right_corner = 0 +8:1/0/terrains_peering_bit/top_right_corner = 0 +9:1/0 = 0 +11:1/0 = 0 +0:2/0 = 0 +1:2/0 = 0 +2:2/0 = 0 +3:2/0 = 0 +4:2/0 = 0 +5:2/0 = 0 +5:2/0/terrain_set = 0 +5:2/0/terrain = 0 +5:2/0/terrains_peering_bit/bottom_right_corner = 0 +5:2/0/terrains_peering_bit/top_left_corner = 0 +5:2/0/terrains_peering_bit/top_right_corner = 0 +6:2/0 = 0 +6:2/0/terrain_set = 0 +6:2/0/terrain = 0 +6:2/0/terrains_peering_bit/bottom_left_corner = 0 +6:2/0/terrains_peering_bit/top_left_corner = 0 +6:2/0/terrains_peering_bit/top_right_corner = 0 +7:2/0 = 0 +8:2/0 = 0 +8:2/0/terrain_set = 0 +9:2/0 = 0 +9:2/0/terrain_set = 0 +9:2/0/terrain = 0 +9:2/0/terrains_peering_bit/bottom_right_corner = 0 +9:2/0/terrains_peering_bit/bottom_left_corner = 0 +9:2/0/terrains_peering_bit/top_left_corner = 0 +9:2/0/terrains_peering_bit/top_right_corner = 0 +10:2/0 = 0 +11:2/0 = 0 +11:2/0/terrain_set = 0 +11:2/0/terrain = 0 +11:2/0/terrains_peering_bit/bottom_left_corner = 0 +11:2/0/terrains_peering_bit/top_left_corner = 0 +0:3/0 = 0 +1:3/0 = 0 +2:3/0 = 0 +3:3/0 = 0 +4:3/0 = 0 +5:3/0 = 0 +6:3/0 = 0 +7:3/0 = 0 +8:3/0 = 0 +8:3/0/terrain_set = 0 +8:3/0/terrain = 0 +8:3/0/terrains_peering_bit/top_right_corner = 0 +9:3/0 = 0 +9:3/0/terrain_set = 0 +9:3/0/terrain = 0 +9:3/0/terrains_peering_bit/top_left_corner = 0 +9:3/0/terrains_peering_bit/top_right_corner = 0 +10:3/0 = 0 +11:3/0 = 0 +11:3/0/terrain_set = 0 +11:3/0/terrain = 0 +11:3/0/terrains_peering_bit/top_left_corner = 0 +0:4/0 = 0 +1:4/0 = 0 +2:4/0 = 0 +3:4/0 = 0 +4:4/0 = 0 + +[sub_resource type="TileSet" id="TileSet_ii6g3"] +terrain_set_0/mode = 1 +terrain_set_0/terrain_0/name = "Terrain 0" +terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1) +sources/0 = SubResource("TileSetAtlasSource_23gwl") + +[node name="TestTerrain2x2" type="Node2D"] + +[node name="TileMap" type="TileMap" parent="."] +tile_set = SubResource("TileSet_ii6g3") +format = 2 +layer_0/tile_data = PackedInt32Array(-1, 589824, 2, -65536, 589824, 2, -65535, 589824, 2, -65534, 589824, 2, -65533, 589824, 2, 1, 589824, 2, 0, 589824, 2, 65535, 589824, 2, -65529, 589824, 2, -65530, 589824, 2, 7, 589824, 2, -131065, 589824, 2, -196601, 589824, 2, -131066, 589824, 2, -196602, 589824, 2, -131072, 589824, 2, -196608, 589824, 2, -65537, 589824, 2, -131073, 589824, 2, -2, 589824, 2, -65538, 589824, 2, -131074, 327680, 1, -3, 327680, 2, -65539, 589824, 2, -131075, 655360, 0, -4, 524288, 3, -65540, 524288, 1, -131076, 524288, 0, 196606, 327680, 2, 131070, 589824, 2, 65534, 589824, 2, 196605, 524288, 3, 131069, 524288, 1, 65533, 524288, 1, 131075, 589824, 2, 65539, 589824, 2, 196610, 589824, 2, 131074, 589824, 2, 65538, 589824, 2, 196609, 589824, 2, 131073, 589824, 2, 65537, 589824, 2, 196608, 589824, 2, 131072, 589824, 2, 65536, 589824, 2, 131077, 589824, 2, -65528, 589824, 2, -65527, 589824, 2, 9, 589824, 2, 10, 720896, 2, 8, 589824, 2, -65526, 720896, 2, -131069, 589824, 2, -196605, 589824, 2, -196606, 589824, 2, -262142, 655360, 0, -262141, 655360, 0, -131070, 589824, 2, 262146, 589824, 2, 327682, 589824, 2, 393218, 589824, 3, 262145, 589824, 2, 327681, 589824, 2, 393217, 589824, 3, 327683, 589824, 2, 327684, 589824, 2, 327685, 589824, 2, 393221, 589824, 3, 393220, 589824, 3, 393219, 589824, 3, 327680, 589824, 2, 393216, 589824, 3, 458751, 589824, 3, 393215, 589824, 2, 393214, 327680, 1, 393213, 655360, 0, 458750, 589824, 3, 458749, 589824, 3, 393211, 655360, 0, 458747, 589824, 3, 458748, 589824, 3, 393212, 655360, 0, 393210, 655360, 0, 458746, 589824, 3, 393209, 393216, 1, 393208, 327680, 2, 458744, 524288, 3, 458745, 589824, 3, 327673, 720896, 2, 327672, 327680, 1, 262136, 524288, 1, 262137, 720896, 2, 196601, 720896, 2, 196600, 327680, 2, -7, 720896, 2, -8, 524288, 1, 65529, 720896, 2, 65528, 524288, 1, 131065, 720896, 2, 131064, 327680, 1, -65543, 720896, 2, -131079, 720896, 0, -65544, 327680, 2, -131080, 655360, 0, -65545, 589824, 3, -131081, 655360, 0, -65546, 524288, 3, -131082, 524288, 0, 196599, 589824, 3, 131063, 655360, 0, 196598, 524288, 3, 131062, 524288, 0, 393207, 524288, 3, 327671, 524288, 0, -196609, 393216, 1, -262145, 720896, 0, -196610, 524288, 1, -262146, 524288, 0, 131081, 589824, 2, 65545, 589824, 2, 131080, 589824, 2, 65544, 589824, 2, 131079, 589824, 2, 393223, 589824, 3, 327687, 589824, 2, 262151, 589824, 2, 196615, 589824, 2, 393222, 589824, 3, 327686, 589824, 2, 262150, 589824, 2, -131067, 589824, 2, -131064, 589824, 2, 196616, 589824, 2, 262147, 589824, 2, 65541, 589824, 2, 262144, 589824, 2, 3, 589824, 2, -196604, 589824, 2, -196603, 589824, 2, -131068, 589824, 2, -65532, 589824, 2, 4, 589824, 2, 131076, 589824, 2, 196612, 589824, 2, 196613, 589824, 2, 131078, 589824, 2, 65542, 589824, 2, 6, 589824, 2, 5, 589824, 2, 262149, 589824, 2, 262148, 589824, 2, 196614, 589824, 2, 327688, 589824, 2, 262152, 589824, 2, -65531, 589824, 2, -262140, 655360, 0, -262143, 655360, 0, -262144, 655360, 0, -131071, 589824, 2, -196607, 589824, 2, -262139, 655360, 0, -262138, 655360, 0, -262137, 655360, 0, -262136, 655360, 0, -196600, 589824, 2, -131063, 589824, 2, -196599, 589824, 2, -262135, 655360, 0, -131062, 720896, 2, -196598, 720896, 2, -262134, 720896, 0, 65546, 720896, 2, 131082, 720896, 2, 196618, 720896, 2, 262154, 720896, 2, 327690, 720896, 2, 262153, 589824, 2, 196617, 589824, 2, 393224, 589824, 3, 393225, 589824, 3, 327689, 589824, 2, 393226, 720896, 3, 327679, 589824, 2, 262143, 589824, 2, 196607, 589824, 2, 131071, 589824, 2, 327678, 524288, 1, 262142, 524288, 1, 196611, 589824, 2, 2, 589824, 2, 65543, 589824, 2, -655350, 655360, 0, -589814, 589824, 2, -589813, 589824, 2, 65540, 589824, 2, -655349, 655360, 0, -589812, 589824, 2, -589811, 589824, 2, -589810, 589824, 2, -589809, 720896, 2, -655345, 720896, 0, -655346, 655360, 0, -655347, 655360, 0, -655348, 655360, 0, -589815, 589824, 2, -655351, 655360, 0, -655352, 655360, 0, -655353, 655360, 0, -589817, 589824, 2, -589816, 589824, 2, -524278, 589824, 2, -524277, 589824, 2, -458741, 589824, 3, -458742, 589824, 3, -524276, 589824, 2, -524275, 589824, 2, -524279, 589824, 2, -524280, 589824, 2, -524281, 589824, 2, -458744, 589824, 3, -458743, 589824, 3, -458740, 589824, 3, -458739, 589824, 3, -458738, 589824, 3, -524274, 589824, 2, -524273, 720896, 2, -458737, 720896, 3, -458745, 589824, 3, -655354, 524288, 0, -589818, 524288, 1, -524282, 524288, 1, -458746, 524288, 3) diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs index b7505c9..2e0bfa8 100644 --- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs @@ -8,10 +8,11 @@ /// public class TileSetTerrainInfo : IClone { - public const byte FloorLayerType = 3; - public const byte MiddleLayerType = 2; public const byte TopLayerType = 1; - + public const byte MiddleLayerType = 2; + public const byte FloorLayerType = 3; + public const byte Terrain2x2Type = 4; + //type = 3 /// /// 地板 (1块) type = 3 diff --git a/DungeonShooting_Godot/src/game/GameConfig.cs b/DungeonShooting_Godot/src/game/GameConfig.cs index 696f91b..1d1e741 100644 --- a/DungeonShooting_Godot/src/game/GameConfig.cs +++ b/DungeonShooting_Godot/src/game/GameConfig.cs @@ -107,7 +107,7 @@ public const float NavigationCellSize = 4; /// - /// 地形掩码纹理大小, 顶部墙壁 + /// 地形掩码纹理大小, 顶部墙壁/47格地形 /// public static readonly Vector2I TerrainBitSize1 = new Vector2I(12, 4); /// @@ -118,4 +118,8 @@ /// 地形掩码纹理大小, 地板 /// public static readonly Vector2I TerrainBitSize3 = new Vector2I(1, 1); + /// + /// 地形掩码纹理大小, 13格地形 + /// + public static readonly Vector2I TerrainBitSize4 = new Vector2I(5, 3); } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs index ee83089..1176d9b 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrain.cs @@ -54,6 +54,15 @@ } /// + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell.ColorRect + /// + public class ColorRect : UiNode + { + public ColorRect(TileSetEditorTerrainPanel uiPanel, Godot.ColorRect node) : base(uiPanel, node) { } + public override ColorRect Clone() => new (UiPanel, (Godot.ColorRect)Instance.Duplicate()); + } + + /// /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.RightCell /// public class RightCell : UiNode @@ -71,6 +80,19 @@ } private CellTexture _L_CellTexture; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.CellRoot.ColorRect + /// + public ColorRect L_ColorRect + { + get + { + if (_L_ColorRect == null) _L_ColorRect = new ColorRect(UiPanel, Instance.GetNode("ColorRect")); + return _L_ColorRect; + } + } + private ColorRect _L_ColorRect; + public RightCell(TileSetEditorTerrainPanel uiPanel, Godot.Control node) : base(uiPanel, node) { } public override RightCell Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate()); } @@ -191,6 +213,37 @@ } /// + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.TerrainTexture4.Label + /// + public class Label_3 : UiNode + { + public Label_3(TileSetEditorTerrainPanel uiPanel, Godot.Label node) : base(uiPanel, node) { } + public override Label_3 Clone() => new (UiPanel, (Godot.Label)Instance.Duplicate()); + } + + /// + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.TerrainTexture4 + /// + public class TerrainTexture4 : UiNode + { + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.Label + /// + public Label_3 L_Label + { + get + { + if (_L_Label == null) _L_Label = new Label_3(UiPanel, Instance.GetNode("Label")); + return _L_Label; + } + } + private Label_3 _L_Label; + + public TerrainTexture4(TileSetEditorTerrainPanel uiPanel, Godot.TextureRect node) : base(uiPanel, node) { } + public override TerrainTexture4 Clone() => new (UiPanel, (Godot.TextureRect)Instance.Duplicate()); + } + + /// /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.Brush /// public class Brush : UiNode @@ -257,6 +310,19 @@ private TerrainTexture3 _L_TerrainTexture3; /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainTexture4 + /// + public TerrainTexture4 L_TerrainTexture4 + { + get + { + if (_L_TerrainTexture4 == null) _L_TerrainTexture4 = new TerrainTexture4(UiPanel, Instance.GetNode("TerrainTexture4")); + return _L_TerrainTexture4; + } + } + private TerrainTexture4 _L_TerrainTexture4; + + /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.Brush /// public Brush L_Brush @@ -292,6 +358,15 @@ } /// + /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainTypeButton + /// + public class TerrainTypeButton : UiNode + { + public TerrainTypeButton(TileSetEditorTerrainPanel uiPanel, Godot.OptionButton node) : base(uiPanel, node) { } + public override TerrainTypeButton Clone() => new (UiPanel, (Godot.OptionButton)Instance.Duplicate()); + } + + /// /// 类型: , 路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg /// public class TopBg : UiNode @@ -335,6 +410,19 @@ } private FocusBtn _L_FocusBtn; + /// + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TerrainTypeButton + /// + public TerrainTypeButton L_TerrainTypeButton + { + get + { + if (_L_TerrainTypeButton == null) _L_TerrainTypeButton = new TerrainTypeButton(UiPanel, Instance.GetNode("TerrainTypeButton")); + return _L_TerrainTypeButton; + } + } + private TerrainTypeButton _L_TerrainTypeButton; + public TopBg(TileSetEditorTerrainPanel uiPanel, UI.TileSetEditorTerrain.TileEditTerrain node) : base(uiPanel, node) { } public override TopBg Clone() => new (UiPanel, (UI.TileSetEditorTerrain.TileEditTerrain)Instance.Duplicate()); } @@ -619,6 +707,11 @@ 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.ColorRect + /// + public ColorRect S_ColorRect => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_CellRoot.L_RightCell.L_ColorRect; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: 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; @@ -639,6 +732,11 @@ public TerrainTexture3 S_TerrainTexture3 => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_TerrainTexture3; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.TerrainTexture4 + /// + public TerrainTexture4 S_TerrainTexture4 => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_TerrainTexture4; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainRoot.Brush /// public Brush S_Brush => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot.L_Brush; @@ -649,6 +747,11 @@ public TerrainRoot S_TerrainRoot => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainRoot; /// + /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg.TerrainTypeButton + /// + public TerrainTypeButton S_TerrainTypeButton => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg.L_TerrainTypeButton; + + /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: TileSetEditorTerrain.VSplitContainer.PanelTop.MarginContainer.TopBg /// public TopBg S_TopBg => L_VSplitContainer.L_PanelTop.L_MarginContainer.L_TopBg; diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs index 5ac8819..b35eb97 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs @@ -18,6 +18,7 @@ public UiGrid TopGrid1; public UiGrid TopGrid2; public UiGrid TopGrid3; + public UiGrid TopGrid4; public UiGrid BottomGrid; private bool _refreshGridConnect = false; @@ -38,9 +39,10 @@ BottomGrid.SetCellOffset(Vector2I.Zero); BottomGrid.GridContainer.MouseFilter = MouseFilterEnum.Ignore; - TopGrid1 = InitTopGrid(S_TerrainRoot.L_TerrainTexture1.Instance, GameConfig.TerrainBitSize1, 1); - TopGrid2 = InitTopGrid(S_TerrainRoot.L_TerrainTexture2.Instance, GameConfig.TerrainBitSize2, 2); - TopGrid3 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance, GameConfig.TerrainBitSize3, 3); + TopGrid1 = InitTopGrid(S_TerrainRoot.L_TerrainTexture1.Instance, GameConfig.TerrainBitSize1, TileSetTerrainInfo.TopLayerType); + TopGrid2 = InitTopGrid(S_TerrainRoot.L_TerrainTexture2.Instance, GameConfig.TerrainBitSize2, TileSetTerrainInfo.MiddleLayerType); + TopGrid3 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance, GameConfig.TerrainBitSize3, TileSetTerrainInfo.FloorLayerType); + TopGrid4 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance, GameConfig.TerrainBitSize4, TileSetTerrainInfo.Terrain2x2Type); OnSetTileTexture(EditorPanel.Texture); OnChangeTileSetBgColor(EditorPanel.BgColor); @@ -95,36 +97,49 @@ TopGrid1.ForEach(cell => ((TerrainCell)cell).ClearCell()); TopGrid2.ForEach(cell => ((TerrainCell)cell).ClearCell()); TopGrid3.ForEach(cell => ((TerrainCell)cell).ClearCell()); + TopGrid4.ForEach(cell => ((TerrainCell)cell).ClearCell()); S_TopBg.Instance.SetHoverCell(null); S_BottomBg.Instance.SetHoverCell(null); - //再加载Terrain var sourceIndex = EditorPanel.TileSetSourceIndex; - if (obj != null) + if (sourceIndex == 0) //选中Main Source时就只能使用 47 Terrain { - var terrain = ((TileSetSourceInfo)obj).Terrain; - TopGrid1.ForEach(cell => SetTerrainCellData(terrain, cell)); - if (sourceIndex == 0) //必须选中Main Source - { - S_TerrainTexture2.Instance.Visible = true; - S_TerrainTexture3.Instance.Visible = true; - TopGrid2.ForEach(cell => SetTerrainCellData(terrain, cell)); - TopGrid3.ForEach(cell => SetTerrainCellData(terrain, cell)); - } - else - { - S_TerrainTexture2.Instance.Visible = false; - S_TerrainTexture3.Instance.Visible = false; - } - } - - if (sourceIndex == 0) - { + S_TerrainTexture2.Instance.Visible = true; + S_TerrainTexture3.Instance.Visible = true; + TopGrid2.Visible = true; + TopGrid3.Visible = true; S_TerrainTexture1.L_Label.Instance.Text = "顶部墙壁"; + S_TerrainTypeButton.Instance.Selected = 0; + S_TerrainTypeButton.Instance.Visible = false; } else { + S_TerrainTexture2.Instance.Visible = false; + S_TerrainTexture3.Instance.Visible = false; + TopGrid2.Visible = false; + TopGrid3.Visible = false; S_TerrainTexture1.L_Label.Instance.Text = "地形"; + S_TerrainTypeButton.Instance.Visible = true; + } + + //再加载Terrain + if (obj != null) + { + var terrain = ((TileSetSourceInfo)obj).Terrain; + if (sourceIndex == 0) //选中Main Source + { + TopGrid1.ForEach(cell => SetTerrainCellData(terrain, cell)); + TopGrid2.ForEach(cell => SetTerrainCellData(terrain, cell)); + TopGrid3.ForEach(cell => SetTerrainCellData(terrain, cell)); + } + else if (S_TerrainTypeButton.Instance.Selected == 0) //选中47个Terrain + { + TopGrid1.ForEach(cell => SetTerrainCellData(terrain, cell)); + } + else //选中13格Terrain + { + TopGrid4.ForEach(cell => SetTerrainCellData(terrain, cell)); + } } } @@ -163,14 +178,14 @@ /// public void OnDropCell(MaskCell maskCell) { - var flag = true; - TopGrid1.ForEach((cell) => + if (EditorPanel.TileSetSourceIndex == 0) //选中Main Source { - flag = !((TerrainCell)cell).OnDropCell(maskCell); - return flag; - }); - if (EditorPanel.TileSetSourceIndex == 0) //必须选中Main Source - { + var flag = true; + TopGrid1.ForEach((cell) => + { + flag = !((TerrainCell)cell).OnDropCell(maskCell); + return flag; + }); if (flag) { TopGrid2.ForEach((cell) => @@ -187,6 +202,20 @@ }); } } + else if (S_TerrainTypeButton.Instance.Selected == 0) //选中47个Terrain + { + TopGrid1.ForEach((cell) => + { + return !((TerrainCell)cell).OnDropCell(maskCell); + }); + } + else //选中13格Terrain + { + TopGrid4.ForEach((cell) => + { + return !((TerrainCell)cell).OnDropCell(maskCell); + }); + } } //改变TileSet纹理 diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainBrush.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainBrush.cs index 96f1db6..243960e 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainBrush.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainBrush.cs @@ -28,32 +28,25 @@ public override void _Draw() { var scale = Root.Scale; - var sourceIndex = _uiNode.UiPanel.EditorPanel.TileSetSourceIndex; //绘制区域 for (var i = 0; i < TerrainTextureList.Count; i++) { - if (sourceIndex != 0 && i > 0) - { - break; - } var control = TerrainTextureList[i]; - DrawRect( - new Rect2(control.Position, control.Size.AsVector2I()), new Color(1, 1, 0, 0.5f), false, - 2f / scale.X - ); + if (control.Visible) + { + DrawRect( + new Rect2(control.Position, control.Size.AsVector2I()), new Color(1, 1, 0, 0.5f), false, + 2f / scale.X + ); + } } - - + //绘制鼠标悬停区域 for (var i = 0; i < TerrainTextureList.Count; i++) { - if (sourceIndex != 0 && i > 0) - { - break; - } var control = TerrainTextureList[i]; - if (control.IsMouseInRect()) + if (control.Visible && control.IsMouseInRect()) { var pos = Utils.GetMouseCellPosition(control) * GameConfig.TileCellSize; DrawRect( diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs index 6bf8aa5..8152bd9 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs @@ -6,6 +6,7 @@ { private bool _dragMoveFlag = false; private TerrainCell _hoverCell = null; + private int _currentTerrainType = 0; public override void SetUiNode(IUiNode uiNode) { @@ -17,9 +18,12 @@ terrainBrush.TerrainTextureList.Add(tileTexture.L_TerrainTexture1.Instance); terrainBrush.TerrainTextureList.Add(tileTexture.L_TerrainTexture2.Instance); terrainBrush.TerrainTextureList.Add(tileTexture.L_TerrainTexture3.Instance); + terrainBrush.TerrainTextureList.Add(tileTexture.L_TerrainTexture4.Instance); //聚焦按钮点击 UiNode.L_FocusBtn.Instance.Pressed += OnFocusClick; + //切换TerrainType按钮点击 + UiNode.L_TerrainTypeButton.Instance.ItemSelected += ChangeTerrainType; } /// @@ -99,12 +103,57 @@ //聚焦按钮点击 private void OnFocusClick() { - var rootSize = UiNode.L_TerrainRoot.Instance.Size; - if (UiNode.UiPanel.EditorPanel.TileSetSourceIndex != 0) + Vector2 rootSize; + if (UiNode.UiPanel.EditorPanel.TileSetSourceIndex == 0) { - rootSize.Y -= 2 * GameConfig.TileCellSize; + rootSize = UiNode.L_TerrainRoot.Instance.Size; + } + else if (UiNode.L_TerrainTypeButton.Instance.Selected == 1) + { + rootSize = UiNode.L_TerrainRoot.L_TerrainTexture4.Instance.Size; + } + else + { + rootSize = UiNode.L_TerrainRoot.L_TerrainTexture1.Instance.Size; } Utils.DoFocusNode(ContainerRoot, Size, rootSize); RefreshGridTrans(); } + + /// + /// 切换Terrain类型 + /// + public void ChangeTerrainType(long index) + { + if (_currentTerrainType == index) + { + return; + } + if (UiNode.UiPanel.EditorPanel.TileSetSourceIndex == 0) //选中 Main Source 时不需要询问 + { + _currentTerrainType = (int)index; + DoChangeTerrainType(index); + return; + } + EditorWindowManager.ShowConfirm("提示", "确定要切换Terrain类型吗?\n该操作将清除所有已经配置好的地形数据!", (v) => + { + if (v) + { + _currentTerrainType = (int)index; + DoChangeTerrainType(index); + } + else + { + UiNode.L_TerrainTypeButton.Instance.Selected = _currentTerrainType; + } + }); + } + + private void DoChangeTerrainType(long index) + { + UiNode.L_TerrainRoot.L_TerrainTexture1.Instance.Visible = index == 0; + UiNode.UiPanel.TopGrid1.Visible = index == 0; + UiNode.L_TerrainRoot.L_TerrainTexture4.Instance.Visible = index != 0; + UiNode.UiPanel.TopGrid4.Visible = index != 0; + } } \ No newline at end of file