diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn index f486d98..1f9085a 100644 --- a/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn +++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorTerrain.tscn @@ -77,12 +77,14 @@ mouse_filter = 2 [node name="RightCell" type="Control" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot/CellRoot"] +z_index = 1 anchors_preset = 0 offset_right = 16.0 offset_bottom = 16.0 mouse_filter = 1 [node name="CellTexture" type="Sprite2D" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot/CellRoot/RightCell"] +z_index = -1 centered = false [node name="TerrainTexture1" type="TextureRect" parent="VSplitContainer/PanelTop/MarginContainer/TopBg/TerrainRoot"] @@ -221,7 +223,7 @@ anchors_preset = 0 offset_right = 16.0 offset_bottom = 16.0 -mouse_filter = 1 +mouse_filter = 2 [node name="MaskBrush" type="Control" parent="VSplitContainer/PanelBottom/MarginContainer/BottomBg/TileTexture"] layout_mode = 1 diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png index d74eba2..cb64efb 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/Test2.png Binary files differ diff --git a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json index a7c8f84..d1a041d 100644 --- a/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json +++ b/DungeonShooting_Godot/resource/map/tileSet/TileSet2/TileSet.json @@ -5,21 +5,90 @@ "Name": "Main", "SourcePath": "resource/map/tileSet/TileSet2/Main.png", "Terrain": { - "F": {}, - "M": { - "1": [ + "F": { + "0": [ 16, - 32 + 144 + ] + }, + "M": { + "3": [ + 160, + 112 ], "2": [ - 32, - 32 + 80, + 112 + ], + "1": [ + 64, + 112 + ], + "0": [ + 0, + 112 ] }, "T": { - "432": [ - 16, + "144": [ + 0, 32 + ], + "507": [ + 224, + 0 + ], + "146": [ + 0, + 48 + ], + "434": [ + 64, + 96 + ], + "18": [ + 0, + 96 + ], + "219": [ + 160, + 80 + ], + "438": [ + 64, + 80 + ], + "63": [ + 96, + 96 + ], + "504": [ + 112, + 0 + ], + "510": [ + 240, + 0 + ], + "506": [ + 192, + 32 + ], + "16": [ + 0, + 0 + ], + "48": [ + 16, + 0 + ], + "56": [ + 32, + 0 + ], + "24": [ + 48, + 0 ] } }, @@ -232,74 +301,71 @@ "Terrain": { "F": {}, "M": {}, - "T": {} + "T": { + "144": [ + 0, + 0 + ], + "48": [ + 16, + 0 + ], + "56": [ + 32, + 0 + ], + "24": [ + 48, + 0 + ], + "250": [ + 64, + 48 + ], + "442": [ + 112, + 48 + ] + } }, "Combination": [ { - "Id": "638404127381228219", - "Name": "\u67F1\u5B50", + "Id": "638404866100310178", + "Name": "\u7EC4\u5408", "Cells": [ { - "X": 224, + "X": 16, + "Y": 48 + }, + { + "X": 32, + "Y": 48 + }, + { + "X": 48, + "Y": 48 + }, + { + "X": 48, "Y": 64 }, { - "X": 224, - "Y": 80 - }, - { - "X": 224, - "Y": 96 - }, - { - "X": 224, + "X": 32, "Y": 64 }, { - "X": 224, - "Y": 80 - }, - { - "X": 224, - "Y": 96 - }, - { - "X": 224, + "X": 16, "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, + "X": 0, "Y": 0 }, { - "X": 48, - "Y": 16 - }, - { - "X": 48, - "Y": 32 + "X": 16, + "Y": 0 }, { "X": 32, @@ -310,32 +376,12 @@ "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 } ] } diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs index 20f313c..9e15f62 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs @@ -15,11 +15,13 @@ /// public MaskCell DraggingCell { get; set; } - private UiGrid _topGrid1; - private UiGrid _topGrid2; - private UiGrid _topGrid3; - private UiGrid _bottomGrid; - + public UiGrid TopGrid1; + public UiGrid TopGrid2; + public UiGrid TopGrid3; + public UiGrid BottomGrid; + + private bool _refreshGridConnect = false; + public override void OnCreateUi() { EditorPanel = (TileSetEditorPanel)ParentUi; @@ -32,12 +34,13 @@ //背景颜色改变 AddEventListener(EventEnum.OnSetTileSetBgColor, OnChangeTileSetBgColor); - _bottomGrid = CreateUiGrid(S_BottomCell); - _bottomGrid.SetCellOffset(Vector2I.Zero); + BottomGrid = CreateUiGrid(S_BottomCell); + 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, 1); + TopGrid2 = InitTopGrid(S_TerrainRoot.L_TerrainTexture2.Instance, GameConfig.TerrainBitSize2, 2); + TopGrid3 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance, GameConfig.TerrainBitSize3, 3); OnSetTileTexture(EditorPanel.Texture); OnChangeTileSetBgColor(EditorPanel.BgColor); @@ -51,6 +54,16 @@ public override void Process(float delta) { S_MaskBrush.Instance.Visible = DraggingCell == null; + + if (_refreshGridConnect) + { + _refreshGridConnect = true; + + var terrain = EditorPanel.TileSetSourceInfo.Terrain; + TopGrid1.ForEach(cell => RefreshConnectTerrainCell(terrain, cell)); + TopGrid2.ForEach(cell => RefreshConnectTerrainCell(terrain, cell)); + TopGrid3.ForEach(cell => RefreshConnectTerrainCell(terrain, cell)); + } } private UiGrid InitTopGrid(Control texture, Vector2I size, byte type) @@ -76,55 +89,66 @@ private void OnSelectTileSetSource(object obj) { //先清除所有绑定的Terrain - _topGrid1.ForEach(cell => ((TerrainCell)cell).ClearCell()); - _topGrid2.ForEach(cell => ((TerrainCell)cell).ClearCell()); - _topGrid3.ForEach(cell => ((TerrainCell)cell).ClearCell()); + TopGrid1.ForEach(cell => ((TerrainCell)cell).ClearCell()); + TopGrid2.ForEach(cell => ((TerrainCell)cell).ClearCell()); + TopGrid3.ForEach(cell => ((TerrainCell)cell).ClearCell()); + S_TopBg.Instance.SetHoverCell(null); + S_BottomBg.Instance.SetHoverCell(null); //再加载Terrain if (obj != null) { var terrain = ((TileSetSourceInfo)obj).Terrain; - _topGrid1.ForEach(cell => - { - var ints = terrain.GetTerrainCell( cell.Index, cell.Data); - if (ints != null) - { - ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); - } - }); - _topGrid2.ForEach(cell => - { - var ints = terrain.GetTerrainCell(cell.Index, cell.Data); - if (ints != null) - { - ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); - } - }); - _topGrid3.ForEach(cell => - { - var ints = terrain.GetTerrainCell( cell.Index, cell.Data); - if (ints != null) - { - ((TerrainCell)cell).SetCell(new Rect2I(ints[0], ints[1], GameConfig.TileCellSize, GameConfig.TileCellSize)); - } - }); + TopGrid1.ForEach(cell => SetTerrainCellData(terrain, cell)); + TopGrid2.ForEach(cell => SetTerrainCellData(terrain, cell)); + TopGrid3.ForEach(cell => SetTerrainCellData(terrain, cell)); + } + } + + private void SetTerrainCellData(TileSetTerrainInfo terrain, UiCell cell) + { + var data = terrain.GetTerrainCell(cell.Index, cell.Data); + if (data != null) + { + var terrainCell = (TerrainCell)cell; + var x = data[0]; + var y = data[1]; + terrainCell.SetCell(new Rect2I(x, y, GameConfig.TileCellSize, GameConfig.TileCellSize)); } } + private void RefreshConnectTerrainCell(TileSetTerrainInfo terrain, UiCell cell) + { + var data = terrain.GetTerrainCell(cell.Index, cell.Data); + if (data != null) + { + var terrainCell = (TerrainCell)cell; + var x = data[0]; + var y = data[1]; + var index = x / GameConfig.TileCellSize + y / GameConfig.TileCellSize * BottomGrid.GetColumns(); + var maskCell = (MaskCell)BottomGrid.GetCell(index); + if (maskCell != null) + { + //绑定TerrainCell + maskCell.SetConnectTerrainCell(terrainCell); + } + } + } + /// /// 放置地形Cell纹理 /// public void OnDropCell(MaskCell maskCell) { var flag = true; - _topGrid1.ForEach((cell) => + TopGrid1.ForEach((cell) => { flag = !((TerrainCell)cell).OnDropCell(maskCell); return flag; }); if (flag) { - _topGrid2.ForEach((cell) => + TopGrid2.ForEach((cell) => { flag = !((TerrainCell)cell).OnDropCell(maskCell); return flag; @@ -132,7 +156,7 @@ } if (flag) { - _topGrid3.ForEach((cell) => + TopGrid3.ForEach((cell) => { return ((TerrainCell)cell).OnDropCell(maskCell); }); @@ -144,21 +168,23 @@ { S_BottomBg.Instance.OnChangeTileSetTexture(); - _bottomGrid.RemoveAll(); + BottomGrid.RemoveAll(); var cellHorizontal = EditorPanel.CellHorizontal; if (cellHorizontal <= 0) { return; } var cellVertical = EditorPanel.CellVertical; - _bottomGrid.SetColumns(cellHorizontal); + BottomGrid.SetColumns(cellHorizontal); for (var y = 0; y < cellVertical; y++) { for (var x = 0; x < cellHorizontal; x++) { - _bottomGrid.Add(new Rect2I(x * GameConfig.TileCellSize, y * GameConfig.TileCellSize, GameConfig.TileCellSize, GameConfig.TileCellSize)); + BottomGrid.Add(new Rect2I(x * GameConfig.TileCellSize, y * GameConfig.TileCellSize, GameConfig.TileCellSize, GameConfig.TileCellSize)); } } + + _refreshGridConnect = true; } //更改背景颜色 diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs index 4df02b3..f37e719 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/MaskCell.cs @@ -4,71 +4,66 @@ public class MaskCell : UiCell { + /// + /// 已经赋值并连接的TerrainCell + /// + public TerrainCell ConnectTerrainCell { get; private set; } + + /// + /// 鼠标是否悬停 + /// + public bool Hover { get; set; } + private TextureRect _textureRect; - private Texture2D _texture; private TileSetEditorTerrainPanel _panel; - private bool _dragMoveFlag = false; public override void OnInit() { _panel = CellNode.UiPanel; _textureRect = _panel.S_BottomBg.L_TileTexture.Instance; - _texture = _textureRect.Texture; CellNode.Instance.Draw += Draw; - CellNode.Instance.AddDragListener(OnDrag); + } + + public override void OnDisable() + { + SetConnectTerrainCell(null); } public override void Process(float delta) { CellNode.Instance.QueueRedraw(); } - - //拖拽操作 - private void OnDrag(DragState state, Vector2 delta) - { - 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) //拖拽移动 + /// + /// 设置连接的Cell + /// + public void SetConnectTerrainCell(TerrainCell terrainCell) + { + if (terrainCell == null) { - if (!_dragMoveFlag) + if (ConnectTerrainCell != null) { - _dragMoveFlag = true; - sprite.Texture = _texture; - sprite.RegionRect = Data; - sprite.Scale = _panel.S_TopBg.L_TerrainRoot.Instance.Scale; - sprite.Visible = true; - sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + ConnectTerrainCell.ConnectMaskCell = null; } - sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + ConnectTerrainCell = null; + } + else if (ConnectTerrainCell != terrainCell) + { + ConnectTerrainCell = terrainCell; + terrainCell.ConnectMaskCell = this; } } private void Draw() { - if (Grid.SelectIndex == Index) + if (Hover || (ConnectTerrainCell != null && ConnectTerrainCell.Hover)) + { + CellNode.Instance.DrawRect( + new Rect2(Vector2.Zero, CellNode.Instance.Size), + new Color(0, 1, 0), false, 3f / _textureRect.Scale.X + ); + } + else if (ConnectTerrainCell != null) { //选中时绘制轮廓 CellNode.Instance.DrawRect( diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TileEditArea.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TileEditArea.cs index 0e2c15e..e35107b 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TileEditArea.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/down/TileEditArea.cs @@ -4,6 +4,9 @@ public partial class TileEditArea : EditorGridBg { + private bool _dragMoveFlag = false; + private MaskCell _hoverCell = null; + public override void SetUiNode(IUiNode uiNode) { base.SetUiNode(uiNode); @@ -14,8 +17,98 @@ //聚焦按钮点击 UiNode.L_FocusBtn.Instance.Pressed += OnFocusClick; + + //拖拽Cell + UiNode.Instance.AddDragListener(OnDrag); } - + + public override void _Process(double delta) + { + MaskCell cell = null; + var _panel = UiNode.UiPanel; + if (_panel.S_BottomBg.Instance.IsMouseInRect() && _panel.S_TileTexture.Instance.IsMouseInRect()) + { + var cellPosition = Utils.GetMouseCellPosition(_panel.S_TileTexture.Instance); + var index = cellPosition.X + cellPosition.Y * _panel.BottomGrid.GetColumns(); + var tempCell = (MaskCell)_panel.BottomGrid.GetCell(index); + if (tempCell.ConnectTerrainCell != null) + { + cell = tempCell; + } + } + SetHoverCell(cell); + } + + /// + /// 设置鼠标悬停Cell + /// + public void SetHoverCell(MaskCell cell) + { + if (cell != _hoverCell) + { + if (_hoverCell != null) + { + _hoverCell.Hover = false; + } + + if (cell != null) + { + cell.Hover = true; + } + + _hoverCell = cell; + } + } + + //拖拽操作 + private void OnDrag(DragState state, Vector2 delta) + { + var _panel = UiNode.UiPanel; + var sprite = _panel.S_DragSprite.Instance; + if (state == DragState.DragStart) //拖拽开始 + { + //这里要判断一下是否在BottomBg和TileTexture区域内 + if (_panel.S_BottomBg.Instance.IsMouseInRect() && _panel.S_TileTexture.Instance.IsMouseInRect()) + { + var cellPosition = Utils.GetMouseCellPosition(_panel.S_TileTexture.Instance); + var index = cellPosition.X + cellPosition.Y * _panel.BottomGrid.GetColumns(); + var cell = (MaskCell)_panel.BottomGrid.GetCell(index); + if (cell.ConnectTerrainCell == null) //必须要没有使用的Cell + { + _panel.DraggingCell = cell; + _panel.BottomGrid.SelectIndex = index; + _dragMoveFlag = false; + } + } + } + else if (state == DragState.DragEnd) //拖拽结束 + { + if (_panel.DraggingCell != null) + { + if (_panel.S_TopBg.Instance.IsMouseInRect()) //找到放置的Cell + { + _panel.OnDropCell(_panel.DraggingCell); + } + sprite.Visible = false; + _dragMoveFlag = false; + _panel.DraggingCell = null; + } + } + else if (_panel.DraggingCell != null) //拖拽移动 + { + if (!_dragMoveFlag) + { + _dragMoveFlag = true; + sprite.Texture = _panel.S_TileTexture.Instance.Texture; + sprite.RegionRect = _panel.DraggingCell.Data; + sprite.Scale = _panel.S_TopBg.L_TerrainRoot.Instance.Scale; + sprite.Visible = true; + sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + } + sprite.GlobalPosition = sprite.GetGlobalMousePosition(); + } + } + /// /// 改变TileSet纹理 /// diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs index 00c9deb..1f987e5 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs @@ -5,6 +5,16 @@ public class TerrainCell : UiCell { /// + /// 已经赋值并连接的MaskCell + /// + public MaskCell ConnectMaskCell { get; set; } + + /// + /// 鼠标是否悬停 + /// + public bool Hover { get; set; } + + /// /// 是否放置了图块 /// public bool IsPutDownTexture { get; private set; } @@ -14,14 +24,20 @@ /// public Vector2I TextureCell { get; private set; } + private Control _root; private TileSetEditorTerrainPanel _panel; public override void OnInit() { _panel = CellNode.UiPanel; + _root = _panel.S_TopBg.L_TerrainRoot.Instance; CellNode.Instance.GuiInput += OnGuiInput; + CellNode.Instance.Draw += OnDraw; } + /// + /// 拖拽放置Cell + /// public bool OnDropCell(MaskCell maskCell) { if (CellNode.Instance.IsMouseInRect()) @@ -33,6 +49,11 @@ return false; } + public override void Process(float delta) + { + CellNode.Instance.QueueRedraw(); + } + private void OnGuiInput(InputEvent @event) { if (@event is InputEventMouseButton mouseEvent) @@ -45,6 +66,10 @@ if (flag) { SetTerrainBitData(null); + if (ConnectMaskCell != null) + { + ConnectMaskCell.SetConnectTerrainCell(null); + } } } } @@ -76,6 +101,14 @@ { SetCell(maskCell.Data); SetTerrainBitData(new []{ TextureCell.X, TextureCell.Y }); + if (ConnectMaskCell != maskCell) + { + if (ConnectMaskCell != null) + { + ConnectMaskCell.SetConnectTerrainCell(null); + } + maskCell.SetConnectTerrainCell(this); + } } private void SetTerrainBitData(int[] cellData) @@ -91,4 +124,15 @@ EventManager.EmitEvent(EventEnum.OnTileSetDirty); } + + private void OnDraw() + { + if (ConnectMaskCell != null && (Hover || ConnectMaskCell.Hover)) + { + CellNode.Instance.DrawRect( + new Rect2(Vector2.Zero, CellNode.Instance.Size), + new Color(0, 1, 0), false, 3f / _root.Scale.X + ); + } + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs index 8a0f43e..4dd5630 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TileEditTerrain.cs @@ -4,6 +4,9 @@ public partial class TileEditTerrain : EditorGridBg { + private bool _dragMoveFlag = false; + private TerrainCell _hoverCell = null; + public override void SetUiNode(IUiNode uiNode) { base.SetUiNode(uiNode); @@ -27,7 +30,68 @@ //UiNode.L_TileTexture.Instance.Size = UiNode.L_TileTexture.Instance.Texture.GetSize(); OnFocusClick(); } + + public override void _Process(double delta) + { + TerrainCell cell = null; + var _panel = UiNode.UiPanel; + if (_panel.S_TopBg.Instance.IsMouseInRect()) + { + if (_panel.S_TerrainTexture1.Instance.IsMouseInRect()) + { + var cellPosition = Utils.GetMouseCellPosition(_panel.S_TerrainTexture1.Instance); + var index = cellPosition.X + cellPosition.Y * _panel.TopGrid1.GetColumns(); + var tempCell = (TerrainCell)_panel.TopGrid1.GetCell(index); + if (tempCell.ConnectMaskCell != null) + { + cell = tempCell; + } + } + if (_panel.S_TerrainTexture2.Instance.IsMouseInRect()) + { + var cellPosition = Utils.GetMouseCellPosition(_panel.S_TerrainTexture2.Instance); + var index = cellPosition.X + cellPosition.Y * _panel.TopGrid2.GetColumns(); + var tempCell = (TerrainCell)_panel.TopGrid2.GetCell(index); + if (tempCell.ConnectMaskCell != null) + { + cell = tempCell; + } + } + if (_panel.S_TerrainTexture3.Instance.IsMouseInRect()) + { + var cellPosition = Utils.GetMouseCellPosition(_panel.S_TerrainTexture3.Instance); + var index = cellPosition.X + cellPosition.Y * _panel.TopGrid3.GetColumns(); + var tempCell = (TerrainCell)_panel.TopGrid3.GetCell(index); + if (tempCell.ConnectMaskCell != null) + { + cell = tempCell; + } + } + } + SetHoverCell(cell); + } + /// + /// 设置鼠标悬停Cell + /// + public void SetHoverCell(TerrainCell cell) + { + if (cell != _hoverCell) + { + if (_hoverCell != null) + { + _hoverCell.Hover = false; + } + + if (cell != null) + { + cell.Hover = true; + } + + _hoverCell = cell; + } + } + //聚焦按钮点击 private void OnFocusClick() {