diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn
index a234b36..84699f6 100644
--- a/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn
+++ b/DungeonShooting_Godot/prefab/ui/MapEditorMapTile.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=7 format=3 uid="uid://tjbfj67t5akm"]
[ext_resource type="Script" path="res://src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs" id="1_gtth6"]
-[ext_resource type="Script" path="res://src/game/ui/mapEditorMapTile/SingleTileTab.cs" id="2_jqu4q"]
+[ext_resource type="Script" path="res://src/game/ui/mapEditorMapTile/FreeTileTab.cs" id="2_5c2no"]
[ext_resource type="Texture2D" uid="uid://d2wslibovwv7w" path="res://resource/sprite/ui/commonIcon/CenterTool.png" id="3_sibps"]
[ext_resource type="Script" path="res://src/game/ui/mapEditorMapTile/TerrainTileTab.cs" id="4_jxcal"]
[ext_resource type="Texture2D" uid="uid://bn47bmilcw4x0" path="res://resource/sprite/ui/commonIcon/Select2.png" id="5_f4thw"]
@@ -49,11 +49,11 @@
size_flags_horizontal = 3
item_count = 3
selected = 0
-popup/item_0/text = "单格"
+popup/item_0/text = "自由绘制"
popup/item_0/id = 0
-popup/item_1/text = "地形"
+popup/item_1/text = "地形绘制"
popup/item_1/id = 1
-popup/item_2/text = "组合"
+popup/item_2/text = "组合绘制"
popup/item_2/id = 2
[node name="Panel" type="Panel" parent="VBoxContainer"]
@@ -73,11 +73,10 @@
theme_override_constants/margin_bottom = 2
[node name="Tab1" type="ColorRect" parent="VBoxContainer/Panel/MarginContainer"]
-visible = false
clip_children = 2
layout_mode = 2
color = Color(0.145098, 0.145098, 0.145098, 1)
-script = ExtResource("2_jqu4q")
+script = ExtResource("2_5c2no")
[node name="TabRoot" type="Control" parent="VBoxContainer/Panel/MarginContainer/Tab1"]
layout_mode = 1
@@ -97,6 +96,12 @@
[node name="TileSprite" type="Sprite2D" parent="VBoxContainer/Panel/MarginContainer/Tab1/TabRoot"]
centered = false
+[node name="Brush" type="Control" parent="VBoxContainer/Panel/MarginContainer/Tab1/TabRoot"]
+anchors_preset = 0
+offset_right = 1.0
+offset_bottom = 1.0
+mouse_filter = 2
+
[node name="Grid" type="ColorRect" parent="VBoxContainer/Panel/MarginContainer/Tab1"]
layout_mode = 1
anchors_preset = 15
@@ -123,6 +128,7 @@
stretch_mode = 5
[node name="Tab2" type="Control" parent="VBoxContainer/Panel/MarginContainer"]
+visible = false
layout_mode = 2
script = ExtResource("4_jxcal")
diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preinstall.json
index 638cd69..8a267ba 100644
--- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preinstall.json
+++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/battle/Battle1/Preinstall.json
@@ -1 +1 @@
-[{"Name":"Preinstall1","Weight":100,"Remark":"","WaveList":[[]]}]
\ No newline at end of file
+[{"Name":"Preinstall1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":31,"Y":-17},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"enemy0001","Weight":100,"Attr":{"Face":"0","Weapon":null},"Altitude":0,"VerticalSpeed":0}]}]]}]
\ 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
index 8f8adc3..5bae412 100644
--- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preinstall.json
+++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start1/Preinstall.json
@@ -1 +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
+[{"Name":"Preinstall1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":16,"Y":-16},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]}]]}]
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/InfiniteGrid.cs b/DungeonShooting_Godot/src/framework/InfiniteGrid.cs
index 20ff181..8fb292b 100644
--- a/DungeonShooting_Godot/src/framework/InfiniteGrid.cs
+++ b/DungeonShooting_Godot/src/framework/InfiniteGrid.cs
@@ -206,4 +206,36 @@
}
}
}
+
+ ///
+ /// 获取网格的包围矩形
+ ///
+ public Rect2I GetRect()
+ {
+ var flag = false;
+ var minX = int.MaxValue;
+ var minY = int.MaxValue;
+ var maxX = int.MinValue;
+ var maxY = int.MinValue;
+ foreach (var pair1 in _map)
+ {
+ var x = pair1.Key;
+ foreach (var pair2 in pair1.Value)
+ {
+ var y = pair2.Key;
+ minX = Mathf.Min(x, minX);
+ minY = Mathf.Min(y, minY);
+ maxX = Mathf.Max(x, maxX);
+ maxY = Mathf.Max(y, maxY);
+ flag = true;
+ }
+ }
+
+ if (!flag)
+ {
+ return new Rect2I();
+ }
+
+ return new Rect2I(minX, minY, maxX - minX + 1, maxY - minY + 1);
+ }
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs
index c366b7a..7d40c8f 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs
@@ -33,6 +33,26 @@
///
Edit,
}
+
+ public enum TileMapDrawMode
+ {
+ ///
+ /// 无状态
+ ///
+ None,
+ ///
+ /// 自由绘制
+ ///
+ Free,
+ ///
+ /// 地形绘制
+ ///
+ Terrain,
+ ///
+ /// 组合绘制
+ ///
+ Combination
+ }
///
/// 所属地图编辑器UI
@@ -85,7 +105,6 @@
private bool _initLayer = false;
//--------- 配置数据 -------------
- private int _sourceId = 0;
private int _terrainSet = 0;
private int _terrain = 0;
private AutoTileConfig _autoTileConfig;
@@ -118,14 +137,27 @@
///
/// 当前正在使用的 Source
///
- public TileSetSourceInfo CurrSource => CurrentTileSet.TileSetInfo.Sources[_sourceId];
-
+ public TileSetSourceInfo CurrSource => CurrentTileSet.TileSetInfo.Sources[CurrSourceIndex];
+
///
/// 当前正在使用的 Source 索引
///
public int CurrSourceIndex { get; private set; }
+
+ ///
+ /// 当前笔刷类型
+ ///
+ public TileMapDrawMode CurrBrushType { get; private set; }
- //变动过的数据
+ ///
+ /// 当前笔刷使用的 AtlasCoords, key: pos, value: atlasCoords
+ ///
+ public List CurrBrush { get; } = new List();
+
+ //笔刷偏移, 单位: 像素
+ private Vector2I _brushOffset = Vector2I.Zero;
+
+ //--------------------------------------- 变动过的数据 ---------------------------------------
///
/// 地图位置, 单位: 格
@@ -202,7 +234,7 @@
_changeFlag = true;
_prevMouseCellPosition = _mouseCellPosition;
//绘制图块
- SetSingleAutoCell(_mouseCellPosition);
+ SetSingleCell(_mouseCellPosition);
}
}
else if (MouseType == MouseButtonType.Area) //绘制区域
@@ -222,7 +254,7 @@
{
_changeFlag = true;
_prevMouseCellPosition = _mouseCellPosition;
- EraseSingleAutoCell(_mouseCellPosition);
+ EraseSingleCell(_mouseCellPosition);
}
}
else if (MouseType == MouseButtonType.Area) //绘制区域
@@ -331,7 +363,7 @@
_changeFlag = false;
if (_drawFullRect) //松开, 提交绘制的矩形区域
{
- SetRectAutoCell(_mouseStartCellPosition, _mouseCellPosition);
+ SetRectCell(_mouseStartCellPosition, _mouseCellPosition);
_drawFullRect = false;
}
}
@@ -350,7 +382,7 @@
_changeFlag = false;
if (_drawFullRect) //松开, 提交擦除的矩形区域
{
- EraseRectAutoCell(_mouseStartCellPosition, _mouseCellPosition);
+ EraseRectCell(_mouseStartCellPosition, _mouseCellPosition);
_drawFullRect = false;
}
}
@@ -387,9 +419,48 @@
MapEditorToolsPanel.S_CurrLayer.Instance.Text = "当前图层:" + layerData.Title;
}
- public void SetCurrentSourceIndex()
+ ///
+ /// 设置选中的 Source 索引
+ ///
+ public void SetCurrSourceIndex(int index)
{
-
+ CurrSourceIndex = index;
+ }
+
+ ///
+ /// 设置当前笔刷类型
+ ///
+ public void SetCurrBrushType(TileMapDrawMode mode)
+ {
+ CurrBrushType = mode;
+ }
+
+ public void AddCurrBrushAtlasCoords(Vector2I atlasCoords)
+ {
+ if (!CurrBrush.Contains(atlasCoords))
+ {
+ CurrBrush.Add(atlasCoords);
+ var xStart = int.MaxValue;
+ var xEnd = int.MinValue;
+ var yStart = int.MaxValue;
+ var yEnd = int.MinValue;
+
+ //计算起始点和终点
+ foreach (var cell in CurrBrush)
+ {
+ xStart = Mathf.Min(cell.X, xStart);
+ yStart = Mathf.Min(cell.Y, yStart);
+ xEnd = Mathf.Max(cell.X, xEnd);
+ yEnd = Mathf.Max(cell.Y, yEnd);
+ }
+
+ _brushOffset = new Vector2I(xEnd - xStart, yEnd - yStart);
+ }
+ }
+
+ public void ClearCurrBrushAtlasCoords()
+ {
+ CurrBrush.Clear();
}
///
@@ -654,13 +725,13 @@
}
}
- //绘制单个自动贴图
- private void SetSingleAutoCell(Vector2I position)
+ //绘制单个贴图
+ private void SetSingleCell(Vector2I position)
{
if (CurrLayer.Layer == MapLayer.AutoFloorLayer) //选择自动地板层, 那么不管笔刷类型, 通通使用 Main Source 中的 Main Terrain
{
var tileCellData = _autoTileConfig.Floor;
- SetCell(GetFloorLayer(), position, tileCellData.SourceId, tileCellData.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, position, tileCellData.SourceId, tileCellData.AutoTileCoords);
if (!_autoCellLayerGrid.Contains(position.X, position.Y))
{
ResetGenerateTimer();
@@ -669,12 +740,18 @@
}
else //自定义层
{
- SetCell(CurrLayer.Layer, position, CurrSourceIndex, new Vector2I(0, 0));
+ if (CurrBrushType == TileMapDrawMode.Free) //自由绘制
+ {
+ foreach (var item in CurrBrush)
+ {
+ SetCell(CurrLayer.Layer, position + item - _brushOffset, CurrSourceIndex, item);
+ }
+ }
}
}
- //绘制区域自动贴图
- private void SetRectAutoCell(Vector2I start, Vector2I end)
+ //绘制区域贴图
+ private void SetRectCell(Vector2I start, Vector2I end)
{
ResetGenerateTimer();
@@ -698,7 +775,7 @@
for (var j = 0; j < height; j++)
{
var tileCellData = _autoTileConfig.Floor;
- SetCell(GetFloorLayer(), new Vector2I(start.X + i, start.Y + j), tileCellData.SourceId, tileCellData.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, new Vector2I(start.X + i, start.Y + j), tileCellData.SourceId, tileCellData.AutoTileCoords);
}
}
@@ -706,11 +783,11 @@
}
//擦除单个图块
- private void EraseSingleAutoCell(Vector2I position)
+ private void EraseSingleCell(Vector2I position)
{
if (CurrLayer.Layer == MapLayer.AutoFloorLayer) //选择自动地板层, 那么不管笔刷类型, 通通使用 Main Source 中的 Main Terrain
{
- EraseCell(GetFloorLayer(), position);
+ EraseCell(MapLayer.AutoFloorLayer, position);
if (_autoCellLayerGrid.Remove(position.X, position.Y))
{
ResetGenerateTimer();
@@ -722,8 +799,8 @@
}
}
- //擦除一个区域内的自动贴图
- private void EraseRectAutoCell(Vector2I start, Vector2I end)
+ //擦除一个区域内的贴图
+ private void EraseRectCell(Vector2I start, Vector2I end)
{
ResetGenerateTimer();
@@ -746,7 +823,7 @@
{
for (var j = 0; j < height; j++)
{
- EraseCell(GetFloorLayer(), new Vector2I(start.X + i, start.Y + j));
+ EraseCell(MapLayer.AutoFloorLayer, new Vector2I(start.X + i, start.Y + j));
}
}
_autoCellLayerGrid.RemoveRect(start, new Vector2I(width, height));
@@ -767,9 +844,9 @@
//重新计算房间区域
private void CalcTileRect(bool refreshDoorTrans)
{
- var rect = GetUsedRect();
- CurrRoomPosition = rect.Position;
- SetMapSize(rect.Size, refreshDoorTrans);
+ var rect = _autoCellLayerGrid.GetRect();
+ CurrRoomPosition = rect.Position - new Vector2I(2, 3);
+ SetMapSize(rect.Size + new Vector2I(4, 5), refreshDoorTrans);
}
//检测是否有不合规的图块, 返回true表示图块正常
@@ -840,7 +917,7 @@
{
tileCellData = _autoTileConfig.Wall_Vertical_Center;
}
- SetCell(GetFloorLayer(), new Vector2I(x, y - 1), tileCellData.SourceId, tileCellData.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, new Vector2I(x, y - 1), tileCellData.SourceId, tileCellData.AutoTileCoords);
}
}
@@ -856,9 +933,9 @@
temp1.Add(p1);
temp1.Add(p2);
//上横
- SetCell(GetFloorLayer(), p1, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, p1, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
//下横
- SetCell(GetFloorLayer(), p2, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, p2, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
}
for (var y = yStart - 4; y <= yEnd + 3; y++)
{
@@ -867,9 +944,9 @@
temp1.Add(p1);
temp1.Add(p2);
//左竖
- SetCell(GetFloorLayer(), p1, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, p1, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
//右竖
- SetCell(GetFloorLayer(), p2, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
+ SetCell(MapLayer.AutoFloorLayer, p2, _autoTileConfig.TopMask.SourceId, _autoTileConfig.TopMask.AutoTileCoords);
}
//计算需要绘制的图块
@@ -895,7 +972,7 @@
//擦除临时边界
for (var i = 0; i < temp1.Count; i++)
{
- EraseCell(GetFloorLayer(), temp1[i]);
+ EraseCell(MapLayer.AutoFloorLayer, temp1[i]);
}
//计算区域
@@ -907,7 +984,7 @@
//擦除临时边界2
for (var i = 0; i < temp2.Count; i++)
{
- EraseCell(GetFloorLayer(), temp2[i]);
+ EraseCell(MapLayer.AutoFloorLayer, temp2[i]);
}
//将墙壁移动到指定层
@@ -964,7 +1041,7 @@
continue;
}
EraseCell(MapLayer.AutoFloorLayer, pos);
- SetCell(layer, pos, _sourceId, atlasCoords);
+ SetCell(layer, pos, CurrSourceIndex, atlasCoords);
}
}
}
@@ -1001,22 +1078,7 @@
{
MapEditorPanel.S_ErrorCellAnimationPlayer.Instance.Stop();
}
-
- private int GetFloorLayer()
- {
- return MapLayer.AutoFloorLayer;
- }
-
- private int GetMiddleLayer()
- {
- return MapLayer.AutoMiddleLayer;
- }
-
- private int GetTopLayer()
- {
- return MapLayer.AutoTopLayer;
- }
-
+
///
/// 选中拖拽功能
///
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/FreeTileTab.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/FreeTileTab.cs
new file mode 100644
index 0000000..2ac7715
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/FreeTileTab.cs
@@ -0,0 +1,151 @@
+using System.Collections.Generic;
+using Godot;
+
+namespace UI.MapEditorMapTile;
+
+///
+/// 自由笔刷页签
+///
+public partial class FreeTileTab : EditorGridBg
+{
+ private ImageTexture _texture;
+ private Sprite2D _sprite;
+ private Control _brush;
+
+ //图像宽度
+ private int _width;
+ //图像高度
+ private int _height;
+ private bool _leftPressed;
+ private Vector2I _prevPos;
+ private List _selectCells = new List();
+
+ public override void SetUiNode(IUiNode uiNode)
+ {
+ base.SetUiNode(uiNode);
+ InitNode(UiNode.L_TabRoot.Instance, UiNode.L_Grid.Instance);
+ _texture = new ImageTexture();
+ _sprite = UiNode.L_TabRoot.L_TileSprite.Instance;
+ _sprite.Texture = _texture;
+
+ _brush = UiNode.L_TabRoot.L_Brush.Instance;
+ _brush.Draw += OnBrushDraw;
+
+ //聚焦按钮
+ UiNode.L_FocusBtn.Instance.Pressed += OnFocusClick;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ _texture.Dispose();
+ }
+
+ public override void _Process(double delta)
+ {
+ if (Visible)
+ {
+ _brush.QueueRedraw();
+ }
+ }
+
+ public override void _GuiInput(InputEvent @event)
+ {
+ base._GuiInput(@event);
+
+ if (@event is InputEventMouseButton mouseButton)
+ {
+ if (mouseButton.ButtonIndex == MouseButton.Left)
+ {
+ _leftPressed = mouseButton.Pressed;
+ if (_leftPressed)
+ {
+ //清理之前的格子
+ _selectCells.Clear();
+ UiNode.UiPanel.EditorTileMap.ClearCurrBrushAtlasCoords();
+ //当前格子
+ var atlasCoords = Utils.GetMouseCellPosition(UiNode.L_TabRoot.Instance);
+ _prevPos = atlasCoords * GameConfig.TileCellSize;
+ _selectCells.Add(_prevPos);
+ UiNode.UiPanel.EditorTileMap.AddCurrBrushAtlasCoords(atlasCoords);
+ }
+ }
+ }
+ else if (_leftPressed && @event is InputEventMouseMotion)
+ {
+ //多选格子
+ var atlasCoords = Utils.GetMouseCellPosition(UiNode.L_TabRoot.Instance);
+ var pos = atlasCoords * GameConfig.TileCellSize;
+ if (pos != _prevPos)
+ {
+ _prevPos = pos;
+ if (!_selectCells.Contains(pos))
+ {
+ _selectCells.Add(pos);
+ UiNode.UiPanel.EditorTileMap.AddCurrBrushAtlasCoords(atlasCoords);
+ }
+ }
+ }
+ }
+
+ ///
+ /// 设置显示的纹理
+ ///
+ public void SetImage(Image image)
+ {
+ _texture.SetImage(image);
+ var texture = UiNode.L_TabRoot.L_TileSprite.Instance.Texture;
+ if (texture != null)
+ {
+ _width = texture.GetWidth();
+ _height = texture.GetHeight();
+ }
+ else
+ {
+ _width = 0;
+ _height = 0;
+ }
+ var root = UiNode.L_TabRoot.Instance;
+ root.Size = new Vector2(_width, _height);
+ }
+
+ //聚焦按钮点击
+ private void OnFocusClick()
+ {
+ Utils.DoFocusNode(ContainerRoot, Size, new Vector2(_width, _height));
+ RefreshGridTrans();
+ }
+
+ //绘制辅助线
+ private void OnBrushDraw()
+ {
+ var root = UiNode.L_TabRoot.Instance;
+ //绘制区域
+ _brush.DrawRect(
+ new Rect2(Vector2.Zero, new Vector2(_width, _height)), new Color(1, 1, 0, 0.5f), false,
+ 2f / root.Scale.X
+ );
+
+ //绘制悬停的区域
+ if (root.IsMouseInRect())
+ {
+ var position = Utils.GetMouseCellPosition(root) * GameConfig.TileCellSize;
+ _brush.DrawRect(
+ new Rect2(position, GameConfig.TileCellSizeVector2I),
+ Colors.Green, false, 3f / root.Scale.X
+ );
+ }
+
+ //绘制选中的格子
+ foreach (var cell in _selectCells)
+ {
+ _brush.DrawRect(
+ new Rect2(cell, GameConfig.TileCellSizeVector2I),
+ Colors.White, false, 2f / root.Scale.X
+ );
+ _brush.DrawRect(
+ new Rect2(cell, GameConfig.TileCellSizeVector2I),
+ new Color(0, 1, 0, 0.1f), true
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs
index 7c00406..303fb6f 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTile.cs
@@ -147,6 +147,15 @@
}
///
+ /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1.TabRoot.Brush
+ ///
+ public class Brush : UiNode
+ {
+ public Brush(MapEditorMapTilePanel uiPanel, Godot.Control node) : base(uiPanel, node) { }
+ public override Brush Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate());
+ }
+
+ ///
/// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1.TabRoot
///
public class TabRoot : UiNode
@@ -164,6 +173,19 @@
}
private TileSprite _L_TileSprite;
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1.Brush
+ ///
+ public Brush L_Brush
+ {
+ get
+ {
+ if (_L_Brush == null) _L_Brush = new Brush(UiPanel, Instance.GetNode("Brush"));
+ return _L_Brush;
+ }
+ }
+ private Brush _L_Brush;
+
public TabRoot(MapEditorMapTilePanel uiPanel, Godot.Control node) : base(uiPanel, node) { }
public override TabRoot Clone() => new (UiPanel, (Godot.Control)Instance.Duplicate());
}
@@ -187,9 +209,9 @@
}
///
- /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1
+ /// 类型: , 路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1
///
- public class Tab1 : UiNode
+ public class Tab1 : UiNode
{
///
/// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.TabRoot
@@ -230,8 +252,8 @@
}
private FocusBtn _L_FocusBtn;
- public Tab1(MapEditorMapTilePanel uiPanel, UI.MapEditorMapTile.SingleTileTab node) : base(uiPanel, node) { }
- public override Tab1 Clone() => new (UiPanel, (UI.MapEditorMapTile.SingleTileTab)Instance.Duplicate());
+ public Tab1(MapEditorMapTilePanel uiPanel, UI.MapEditorMapTile.FreeTileTab node) : base(uiPanel, node) { }
+ public override Tab1 Clone() => new (UiPanel, (UI.MapEditorMapTile.FreeTileTab)Instance.Duplicate());
}
///
@@ -412,13 +434,13 @@
public class MarginContainer : UiNode
{
///
- /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.Tab1
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.Tab1
///
public Tab1 L_Tab1
{
get
{
- if (_L_Tab1 == null) _L_Tab1 = new Tab1(UiPanel, Instance.GetNode("Tab1"));
+ if (_L_Tab1 == null) _L_Tab1 = new Tab1(UiPanel, Instance.GetNode("Tab1"));
return _L_Tab1;
}
}
@@ -551,6 +573,11 @@
public TileSprite S_TileSprite => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab1.L_TabRoot.L_TileSprite;
///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1.TabRoot.Brush
+ ///
+ public Brush S_Brush => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab1.L_TabRoot.L_Brush;
+
+ ///
/// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1.TabRoot
///
public TabRoot S_TabRoot => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab1.L_TabRoot;
@@ -566,7 +593,7 @@
public FocusBtn S_FocusBtn => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab1.L_FocusBtn;
///
- /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorMapTile.VBoxContainer.Panel.MarginContainer.Tab1
///
public Tab1 S_Tab1 => L_VBoxContainer.L_Panel.L_MarginContainer.L_Tab1;
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs
index 26d2c9d..47106d3 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/MapEditorMapTilePanel.cs
@@ -1,4 +1,5 @@
using Godot;
+using UI.MapEditor;
namespace UI.MapEditorMapTile;
@@ -28,9 +29,16 @@
return TileSetSplit.TileSetInfo.Sources[SourceIndex];
}
}
+
+ ///
+ /// 编辑器Tile对象
+ ///
+ public EditorTileMap EditorTileMap { get; private set; }
public override void OnCreateUi()
{
+ var editorPanel = (MapEditorPanel)ParentUi;
+ EditorTileMap = editorPanel.S_TileMap.Instance;
//切换资源
S_SourceOption.Instance.ItemSelected += OnChangeSource;
//切换笔刷类型
@@ -72,6 +80,7 @@
//地形页签
S_Tab2.Instance.RefreshTerrain(sourceInfo);
}
+ EditorTileMap.SetCurrSourceIndex(SourceIndex);
}
//切换笔刷类型
@@ -80,17 +89,24 @@
var v1 = false;
var v2 = false;
var v3 = false;
- if (index == 0) //单格
+ if (index == 0) //自由绘制
{
v1 = true;
+ EditorTileMap.SetCurrBrushType(EditorTileMap.TileMapDrawMode.Free);
}
else if (index == 1) //地形
{
v2 = true;
+ EditorTileMap.SetCurrBrushType(EditorTileMap.TileMapDrawMode.Terrain);
}
else if (index == 2) //组合
{
v3 = true;
+ EditorTileMap.SetCurrBrushType(EditorTileMap.TileMapDrawMode.Combination);
+ }
+ else
+ {
+ EditorTileMap.SetCurrBrushType(EditorTileMap.TileMapDrawMode.Free);
}
S_Tab1.Instance.Visible = v1;
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/SingleTileTab.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/SingleTileTab.cs
deleted file mode 100644
index 9b4fdaa..0000000
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapTile/SingleTileTab.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Godot;
-
-namespace UI.MapEditorMapTile;
-
-///
-/// 单格笔刷页签
-///
-public partial class SingleTileTab : EditorGridBg
-{
- private ImageTexture _texture;
-
- public override void SetUiNode(IUiNode uiNode)
- {
- base.SetUiNode(uiNode);
- InitNode(UiNode.L_TabRoot.Instance, UiNode.L_Grid.Instance);
- _texture = new ImageTexture();
- UiNode.L_TabRoot.L_TileSprite.Instance.Texture = _texture;
-
- //聚焦按钮
- UiNode.L_FocusBtn.Instance.Pressed += OnFocusClick;
- }
-
- protected override void Dispose(bool disposing)
- {
- _texture.Dispose();
- }
-
- public void SetImage(Image image)
- {
- _texture.SetImage(image);
- }
-
- //聚焦按钮点击
- private void OnFocusClick()
- {
- var texture = UiNode.L_TabRoot.L_TileSprite.Instance.Texture;
- Utils.DoFocusNode(ContainerRoot, Size, texture != null ? texture.GetSize() : Vector2.Zero);
- RefreshGridTrans();
- }
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
index 7b3bc32..dbd6445 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs
@@ -227,20 +227,16 @@
}
}
- //擦除笔刷
+ //擦除操作
private void EraseBrush()
{
var brushRoot = UiNode.L_CombinationRoot.L_BrushRoot.Instance;
- foreach (var keyValuePair in _brushData)
+ var pos = brushRoot.Position.AsVector2I();
+ if (_canvas.TryGetValue(pos, out var canvasCell))
{
- var combinationCell = keyValuePair.Value;
- var pos = (combinationCell.Position + brushRoot.Position).AsVector2I();
- if (_canvas.TryGetValue(pos, out var canvasCell))
- {
- canvasCell.QueueFree();
- _canvas.Remove(pos);
- _canvasDirty = true;
- }
+ canvasCell.QueueFree();
+ _canvas.Remove(pos);
+ _canvasDirty = true;
}
}