diff --git a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs index 250aea8..d355f55 100644 --- a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs +++ b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs @@ -95,7 +95,7 @@ return false; } - var size = control.Size; + var size = control.Size * control.Scale; return pos.X <= size.X - border && pos.Y <= size.Y - border; } diff --git a/DungeonShooting_Godot/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index f2af8b2..61a0b52 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -213,17 +213,6 @@ } /// - /// 返回指定坐标是否在UI节范围点内 - /// - public static bool IsPositionOver(this Control control, Vector2 position) - { - var globalPosition = control.GlobalPosition; - var size = control.Size * control.Scale; - return position.X >= globalPosition.X && position.X <= (globalPosition.X + size.X) && - position.Y >= globalPosition.Y && position.Y <= (globalPosition.Y + size.Y); - } - - /// /// 判断点是否在区域内 /// public static bool IsPositionInRect(Vector2 pos, Rect2 rect2) diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs index 20f6d7f..c366b7a 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMap.cs @@ -104,6 +104,26 @@ /// 地图是否有绘制错误 /// public bool HasTerrainError => !_isGenerateTerrain; + + /// + /// 当前选择的图层 + /// + public TileMapLayerData CurrLayer { get; private set; } + + /// + /// 当前正在使用的 TileSetSplit 数据 + /// + public TileSetSplit CurrentTileSet { get; private set; } + + /// + /// 当前正在使用的 Source + /// + public TileSetSourceInfo CurrSource => CurrentTileSet.TileSetInfo.Sources[_sourceId]; + + /// + /// 当前正在使用的 Source 索引 + /// + public int CurrSourceIndex { get; private set; } //变动过的数据 @@ -170,7 +190,7 @@ _mouseCellPosition.Y * GameConfig.TileCellSize ); - if (!MapEditorToolsPanel.S_HBoxContainer.Instance.IsPositionOver(GetGlobalMousePosition())) //不在Ui节点上 + if (!MapEditorToolsPanel.S_HBoxContainer.Instance.IsMouseInRect()) //不在Ui节点上 { //左键绘制 if (_isLeftPressed) @@ -181,7 +201,7 @@ { _changeFlag = true; _prevMouseCellPosition = _mouseCellPosition; - //绘制自动图块 + //绘制图块 SetSingleAutoCell(_mouseCellPosition); } } @@ -359,6 +379,20 @@ } /// + /// 设置选择的layer + /// + public void SetCurrentLayer(TileMapLayerData layerData) + { + CurrLayer = layerData; + MapEditorToolsPanel.S_CurrLayer.Instance.Text = "当前图层:" + layerData.Title; + } + + public void SetCurrentSourceIndex() + { + + } + + /// /// 尝试运行检查, 如果已经运行过了, 则没有效果 /// public void TryRunCheckHandler() @@ -561,6 +595,7 @@ /// 要初始化的图块集 private void InitTileSet(TileSetSplit tileSetSplit) { + CurrentTileSet = tileSetSplit; TileSet = tileSetSplit.GetTileSet(); // 创建AutoTileConfig对象 @@ -622,13 +657,19 @@ //绘制单个自动贴图 private void SetSingleAutoCell(Vector2I position) { - var tileCellData = _autoTileConfig.Floor; - SetCell(GetFloorLayer(), position, tileCellData.SourceId, tileCellData.AutoTileCoords); - //SetCell(GetFloorLayer(), position, _sourceId, _autoTileConfig.Floor.AutoTileCoords); - if (!_autoCellLayerGrid.Contains(position.X, position.Y)) + if (CurrLayer.Layer == MapLayer.AutoFloorLayer) //选择自动地板层, 那么不管笔刷类型, 通通使用 Main Source 中的 Main Terrain { - ResetGenerateTimer(); - _autoCellLayerGrid.Set(position.X, position.Y, true); + var tileCellData = _autoTileConfig.Floor; + SetCell(GetFloorLayer(), position, tileCellData.SourceId, tileCellData.AutoTileCoords); + if (!_autoCellLayerGrid.Contains(position.X, position.Y)) + { + ResetGenerateTimer(); + _autoCellLayerGrid.Set(position.X, position.Y, true); + } + } + else //自定义层 + { + SetCell(CurrLayer.Layer, position, CurrSourceIndex, new Vector2I(0, 0)); } } @@ -664,13 +705,20 @@ _autoCellLayerGrid.SetRect(start, new Vector2I(width, height), true); } - //擦除单个自动图块 + //擦除单个图块 private void EraseSingleAutoCell(Vector2I position) { - EraseCell(GetFloorLayer(), position); - if (_autoCellLayerGrid.Remove(position.X, position.Y)) + if (CurrLayer.Layer == MapLayer.AutoFloorLayer) //选择自动地板层, 那么不管笔刷类型, 通通使用 Main Source 中的 Main Terrain { - ResetGenerateTimer(); + EraseCell(GetFloorLayer(), position); + if (_autoCellLayerGrid.Remove(position.X, position.Y)) + { + ResetGenerateTimer(); + } + } + else //自定义层 + { + EraseCell(CurrLayer.Layer, position); } } @@ -1152,6 +1200,12 @@ tileInfo.Floor.Clear(); tileInfo.Middle.Clear(); tileInfo.Top.Clear(); + tileInfo.CustomFloor1.Clear(); + tileInfo.CustomFloor2.Clear(); + tileInfo.CustomFloor3.Clear(); + tileInfo.CustomMiddle1.Clear(); + tileInfo.CustomMiddle2.Clear(); + tileInfo.CustomTop.Clear(); //保存图块数据 PushAutoLayerDataToList(MapLayer.AutoFloorLayer, tileInfo.Floor); diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/LayerButtonCell.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/LayerButtonCell.cs index ca25057..537ea0a 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/LayerButtonCell.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapLayer/LayerButtonCell.cs @@ -72,6 +72,7 @@ public override void OnSelect() { CellNode.L_SelectTexture.Instance.Visible = true; + CellNode.UiPanel.EditorTileMap.SetCurrentLayer(Data); } public override void OnUnSelect()