鼠标右键选择图块功能, 开发中
1 parent 41a51fb commit 1bfdc2ed65cf13f44623510240e058cd826272ba
@小李xl 小李xl authored on 15 Dec 2023
Showing 14 changed files
View
69
DungeonShooting_Godot/prefab/ui/TileSetEditorSegment.tscn
[gd_scene load_steps=7 format=3 uid="uid://daias2tkvj20c"]
[gd_scene load_steps=9 format=3 uid="uid://daias2tkvj20c"]
 
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileSetEditorSegmentPanel.cs" id="1_to1lc"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileEditArea.cs" id="2_h43yx"]
[ext_resource type="Shader" path="res://resource/material/Grid.gdshader" id="2_t1p2n"]
[ext_resource type="Texture2D" uid="uid://uhhfgdhpk7i4" path="res://icon.png" id="2_wr143"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/MaskBrush.cs" id="4_ytys0"]
[ext_resource type="Script" path="res://src/game/ui/tileSetEditorSegment/TileSelectedCell.cs" id="6_ebs5u"]
[ext_resource type="Texture2D" uid="uid://bn47bmilcw4x0" path="res://resource/sprite/ui/commonIcon/Select2.png" id="6_g5ey6"]
 
[sub_resource type="ShaderMaterial" id="ShaderMaterial_u3xqn"]
shader = ExtResource("2_t1p2n")
shader_parameter/color = Color(0.529412, 0.529412, 0.529412, 0.0431373)
 
[node name="Left" type="Panel" parent="HSplitContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 70.0
size_flags_stretch_ratio = 68.0
 
[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/Left"]
layout_mode = 1
anchors_preset = 15
 
[node name="Right" type="Panel" parent="HSplitContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 30.0
size_flags_stretch_ratio = 31.0
 
[node name="MarginContainer" type="MarginContainer" parent="HSplitContainer/Right"]
layout_mode = 1
anchors_preset = 15
theme_override_constants/margin_top = 2
theme_override_constants/margin_right = 2
theme_override_constants/margin_bottom = 2
 
[node name="RightBg" type="VBoxContainer" parent="HSplitContainer/Right/MarginContainer"]
layout_mode = 2
script = ExtResource("6_ebs5u")
 
[node name="Label" type="Label" parent="HSplitContainer/Right/MarginContainer/RightBg"]
layout_mode = 2
text = "已经导入的图块(右键移除):"
 
[node name="ScrollContainer" type="ScrollContainer" parent="HSplitContainer/Right/MarginContainer/RightBg"]
layout_mode = 2
size_flags_vertical = 3
 
[node name="CellButton" type="Button" parent="HSplitContainer/Right/MarginContainer/RightBg/ScrollContainer"]
custom_minimum_size = Vector2(120, 145)
layout_mode = 2
 
[node name="PreviewImage" type="TextureRect" parent="HSplitContainer/Right/MarginContainer/RightBg/ScrollContainer/CellButton"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 2.0
offset_top = 2.0
offset_right = -2.0
offset_bottom = -27.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
stretch_mode = 5
 
[node name="CellId" type="Label" parent="HSplitContainer/Right/MarginContainer/RightBg/ScrollContainer/CellButton"]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -27.0
offset_bottom = -3.0
grow_horizontal = 2
grow_vertical = 0
theme_override_font_sizes/font_size = 16
text = "(0,0)"
horizontal_alignment = 1
vertical_alignment = 1
clip_text = true
text_overrun_behavior = 1
 
[node name="SelectTexture" type="NinePatchRect" parent="HSplitContainer/Right/MarginContainer/RightBg/ScrollContainer/CellButton"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("6_g5ey6")
region_rect = Rect2(0, 0, 36, 36)
patch_margin_left = 3
patch_margin_top = 3
patch_margin_right = 3
patch_margin_bottom = 3
View
28
DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs
 
/// <summary>
/// 给TileMap添加轮廓, 该函数为协程函数
/// </summary>
/// <param name="tileCellInfo">描轮廓的Tile</param>
public IEnumerator AddOutlineTile(TileCellInfo tileCellInfo)
/// <param name="tileCellData">描轮廓的Tile</param>
public IEnumerator AddOutlineTile(TileCellData tileCellData)
{
var c = 0;
var rect = _tileRoot.GetUsedRect();
var endX = rect.End.X + 1;
var pos = new Vector2I(x, y);
var flag1 = _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, pos) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, pos) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.AisleFloorMapLayer, pos) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, pos) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, pos) != tileCellInfo.AutoTileCoord);
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, pos) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, pos) != tileCellData.AutoTileCoord);
if (!flag1) //空地
{
var posDown = new Vector2I(pos.X, pos.Y + 1);
var posTop = new Vector2I(pos.X, pos.Y - 1);
var posRT = new Vector2I(pos.X + 1, pos.Y - 1);
var flag2 = _tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posDown) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posDown) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posDown) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posDown) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posDown) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posDown) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posTop) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posTop) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posTop) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posTop) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posTop) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posTop) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLeft) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLeft) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLeft) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLeft) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLeft) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLeft) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRight) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRight) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRight) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRight) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRight) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRight) != tileCellData.AutoTileCoord) ||
//
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLD) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLD) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLD) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLD) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posLT) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posLT) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLT) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posLT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posLT) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRD) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRD) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRD) != tileCellInfo.AutoTileCoord) ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRD) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRD) != tileCellData.AutoTileCoord) ||
 
_tileRoot.GetCellSourceId(GameConfig.FloorMapLayer, posRT) != -1 ||
_tileRoot.GetCellSourceId(GameConfig.MiddleMapLayer, posRT) != -1 ||
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRT) != tileCellInfo.AutoTileCoord);
(_tileRoot.GetCellSourceId(GameConfig.TopMapLayer, posRT) != -1 && _tileRoot.GetCellAtlasCoords(GameConfig.TopMapLayer, posRT) != tileCellData.AutoTileCoord);
if (flag2) //非空地, 那么说明这个点需要填充 WALL_BLOCK
{
_tileRoot.SetCell(GameConfig.TopMapLayer, pos, tileCellInfo.Id, tileCellInfo.AutoTileCoord);
_tileRoot.SetCell(GameConfig.TopMapLayer, pos, tileCellData.Id, tileCellData.AutoTileCoord);
}
}
}
}
}
//填充tile区域
private void FillRect(int layer, TileCellInfo info, Vector2 pos, Vector2 size)
private void FillRect(int layer, TileCellData data, Vector2 pos, Vector2 size)
{
for (int i = 0; i < size.X; i++)
{
for (int j = 0; j < size.Y; j++)
if (layer == GameConfig.AisleFloorMapLayer)
{
_tempAisleFloorGrid.Set(p, true);
}
_tileRoot.SetCell(layer, p, 0, info.AutoTileCoord);
_tileRoot.SetCell(layer, p, 0, data.AutoTileCoord);
}
}
}
 
View
DungeonShooting_Godot/src/framework/map/TileCellData.cs 0 → 100644
View
DungeonShooting_Godot/src/framework/map/TileCellInfo.cs 100644 → 0
View
DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs
View
DungeonShooting_Godot/src/game/manager/ResourcePath.cs
View
DungeonShooting_Godot/src/game/room/AutoTileConfig.cs
View
DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
View
DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
View
DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/MaskRectCell.cs
View
DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileCell.cs 0 → 100644
View
DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileEditArea.cs
View
DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSelectedCell.cs 0 → 100644
View
DungeonShooting_Godot/src/game/ui/tileSetEditorSegment/TileSetEditorSegment.cs