diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json
index 9ee2b94..65519d9 100644
--- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json
+++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json
@@ -1 +1 @@
-[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":1,"Y":-53},"Size":{"X":20,"Y":10},"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]},{"Position":{"X":1,"Y":-36},"Size":{"X":21,"Y":20},"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]},{"Position":{"X":5,"Y":15},"Size":{"X":50,"Y":20},"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]}]]}]
\ No newline at end of file
+[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":-44,"Y":-58},"Size":{"X":20,"Y":10},"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]},{"Position":{"X":0,"Y":-53},"Size":{"X":50,"Y":20},"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]}],[{"Position":{"X":-43,"Y":-20},"Size":{"X":40,"Y":23},"DelayTime":0,"MarkList":[{"Id":"weapon0005","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]},{"Position":{"X":9,"Y":-20},"Size":{"X":30,"Y":30},"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"0","ResidueAmmo":"0"}}]}]]}]
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/ui/grid/IUiGrid.cs b/DungeonShooting_Godot/src/framework/ui/grid/IUiGrid.cs
index 989bd45..0fad5c1 100644
--- a/DungeonShooting_Godot/src/framework/ui/grid/IUiGrid.cs
+++ b/DungeonShooting_Godot/src/framework/ui/grid/IUiGrid.cs
@@ -19,4 +19,9 @@
/// 当前网格组件数据大小
///
int Count { get; }
+
+ ///
+ /// 触发点击 Cell
+ ///
+ void Click(int index);
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs
index 6df6551..c31c27c 100644
--- a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs
+++ b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs
@@ -324,7 +324,17 @@
ReclaimCellInstance(uiCell);
}
}
-
+
+ public void Click(int index)
+ {
+ if (index < 0 || index >= _cellList.Count)
+ {
+ return;
+ }
+
+ _cellList[index].Click();
+ }
+
///
/// 销毁当前网格组件
///
diff --git a/DungeonShooting_Godot/src/game/event/EventEnum.cs b/DungeonShooting_Godot/src/game/event/EventEnum.cs
index 22d34e4..f597e42 100644
--- a/DungeonShooting_Godot/src/game/event/EventEnum.cs
+++ b/DungeonShooting_Godot/src/game/event/EventEnum.cs
@@ -88,7 +88,7 @@
///
/// 选中编辑门区域工具
///
- OnSelectDoorTool,
+ OnSelectEditTool,
///
/// 点击跳转到地图中心点
///
@@ -98,6 +98,10 @@
///
OnSelectPreinstall,
///
+ /// 选中波数, 参数或者null
+ ///
+ OnSelectWave,
+ ///
/// 创建标记, 参数
///
OnCreateMark,
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/TileView/EditorTileMap.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/TileView/EditorTileMap.cs
index 1359cb6..afca70a 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditor/TileView/EditorTileMap.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditor/TileView/EditorTileMap.cs
@@ -29,9 +29,9 @@
///
Area,
///
- /// 编辑门区域模式
+ /// 编辑工具模式
///
- Door,
+ Edit,
}
///
@@ -72,7 +72,7 @@
///
/// 左键功能
///
- public MouseButtonType MouseType { get; set; } = MouseButtonType.Pen;
+ public MouseButtonType MouseType { get; private set; } = MouseButtonType.Pen;
//鼠标坐标
private Vector2 _mousePosition;
@@ -159,6 +159,11 @@
}
}
+ ///
+ /// 选中的标记
+ ///
+ public MarkTool SelectMark => MapEditorToolsPanel.ActiveMark;
+
//变动过的数据
//地图位置, 单位: 格
@@ -807,9 +812,9 @@
///
/// 选择编辑门区域
///
- public void OnSelectDoorTool(object arg)
+ public void OnSelectEditTool(object arg)
{
- MouseType = MouseButtonType.Door;
+ MouseType = MouseButtonType.Edit;
}
///
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMapBar.cs b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMapBar.cs
index aa73a0b..1c9826f 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMapBar.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditor/tileView/EditorTileMapBar.cs
@@ -12,14 +12,13 @@
_editorTileMap = editorTileMap;
_editorTileMap.Instance.MapEditorPanel = editorPanel;
_editorTileMap.Instance.MapEditorToolsPanel = editorPanel.S_MapEditorTools.Instance;
- _editorTileMap.Instance.MapEditorToolsPanel.EditorMap = _editorTileMap;
_editorTileMap.L_Brush.Instance.Draw += OnDrawGuides;
_eventFactory = EventManager.CreateEventFactory();
_eventFactory.AddEventListener(EventEnum.OnSelectDragTool, _editorTileMap.Instance.OnSelectHandTool);
_eventFactory.AddEventListener(EventEnum.OnSelectPenTool, _editorTileMap.Instance.OnSelectPenTool);
_eventFactory.AddEventListener(EventEnum.OnSelectRectTool, _editorTileMap.Instance.OnSelectRectTool);
- _eventFactory.AddEventListener(EventEnum.OnSelectDoorTool, _editorTileMap.Instance.OnSelectDoorTool);
+ _eventFactory.AddEventListener(EventEnum.OnSelectEditTool, _editorTileMap.Instance.OnSelectEditTool);
_eventFactory.AddEventListener(EventEnum.OnClickCenterTool, _editorTileMap.Instance.OnClickCenterTool);
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorMarkCell.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorMarkCell.cs
index d5849cf..6923e3e 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorMarkCell.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorMarkCell.cs
@@ -1,4 +1,5 @@
using Config;
+using UI.MapEditor;
namespace UI.MapEditorMapMark;
@@ -38,14 +39,23 @@
public override void OnClick()
{
+ CellNode.UiPanel.EditorTileMap.SelectWaveIndex = Data.ParentCell.Index;
+ //派发选中波数事件
+ EventManager.EmitEvent(EventEnum.OnSelectWave, Data.ParentCell.Index);
CellNode.UiPanel.SetSelectCell(this, CellNode.Instance, MapEditorMapMarkPanel.SelectToolType.Mark);
+ //需要切换回编辑工具
+ if (CellNode.UiPanel.EditorTileMap.MouseType != EditorTileMap.MouseButtonType.Edit)
+ {
+ //选中标记
+ EventManager.EmitEvent(EventEnum.OnSelectMark, Data.MarkInfo);
+ }
}
public override void OnSelect()
{
CellNode.L_MarkButton.L_Select.Instance.Visible = true;
//选中标记
- EventManager.EmitEvent(EventEnum.OnSelectMark, Data);
+ EventManager.EmitEvent(EventEnum.OnSelectMark, Data.MarkInfo);
}
public override void OnUnSelect()
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorWaveCell.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorWaveCell.cs
index a345772..08adf3a 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorWaveCell.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/EditorWaveCell.cs
@@ -27,7 +27,7 @@
var array = new MapEditorMapMarkPanel.MarkCellData[data.Count];
for (var i = 0; i < data.Count; i++)
{
- array[i] = new MapEditorMapMarkPanel.MarkCellData(Grid, data[i]);
+ array[i] = new MapEditorMapMarkPanel.MarkCellData(this, data[i]);
}
MarkGrid.SetDataList(array);
}
@@ -54,9 +54,12 @@
{
var preinstall = CellNode.UiPanel.GetSelectPreinstall();
preinstall.WaveList[Index].Add(markInfo);
- MarkGrid.Add(new MapEditorMapMarkPanel.MarkCellData(Grid, markInfo));
+ MarkGrid.Add(new MapEditorMapMarkPanel.MarkCellData(this, markInfo));
//添加标记工具
EventManager.EmitEvent(EventEnum.OnCreateMark, markInfo);
+ //选中最后一个
+ //MarkGrid.SelectIndex
+ MarkGrid.Click(MarkGrid.Count - 1);
}
///
@@ -90,6 +93,8 @@
public override void OnClick()
{
CellNode.UiPanel.EditorTileMap.SelectWaveIndex = Index;
+ //派发选中波数事件
+ EventManager.EmitEvent(EventEnum.OnSelectWave, Index);
CellNode.UiPanel.SetSelectCell(this, CellNode.L_WaveContainer.Instance, MapEditorMapMarkPanel.SelectToolType.Wave);
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/MapEditorMapMarkPanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/MapEditorMapMarkPanel.cs
index 6d350c4..9f80c35 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/MapEditorMapMarkPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorMapMark/MapEditorMapMarkPanel.cs
@@ -15,12 +15,12 @@
public class MarkCellData
{
- public UiGrid> ParentGrid;
+ public EditorWaveCell ParentCell;
public MarkInfo MarkInfo;
- public MarkCellData(UiGrid> parentGrid, MarkInfo markInfo)
+ public MarkCellData(EditorWaveCell parentCell, MarkInfo markInfo)
{
- ParentGrid = parentGrid;
+ ParentCell = parentCell;
MarkInfo = markInfo;
}
}
@@ -106,7 +106,7 @@
waveCell.OnExpandOrClose();
}
//选中物体
- SetSelectCell(cell, cell.CellNode.Instance, SelectToolType.Mark);
+ cell.OnClick();
}
}
}
@@ -330,6 +330,8 @@
selectPreinstall.WaveList.RemoveAt(index);
_grid.RemoveByIndex(index);
EditorTileMap.SelectWaveIndex = -1;
+ //派发选中波数事件
+ EventManager.EmitEvent(EventEnum.OnSelectWave, -1);
}
///
@@ -345,7 +347,6 @@
///
public void OnDeleteMark()
{
-
if (SelectCell is EditorMarkCell markCell)
{
var index = EditorTileMap.SelectWaveIndex;
@@ -364,11 +365,12 @@
//隐藏工具
S_DynamicTool.Reparent(this);
S_DynamicTool.Instance.Visible = false;
- var markInfo = waveCell.Data[index];
+ var markCellIndex = markCell.Index;
+ var markInfo = waveCell.Data[markCellIndex];
//派发移除标记事件
EventManager.EmitEvent(EventEnum.OnDeleteMark, markInfo);
- waveCell.MarkGrid.RemoveByIndex(index);
- waveCell.Data.RemoveAt(index);
+ waveCell.MarkGrid.RemoveByIndex(markCellIndex);
+ waveCell.Data.RemoveAt(markCellIndex);
}
}
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
index fa3ec60..6d2eac0 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
@@ -424,7 +424,7 @@
private void OnMouseEntered()
{
- if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
@@ -433,7 +433,7 @@
private void OnMouseExited()
{
- if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
index 226a9f5..6f81623 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
@@ -65,7 +65,7 @@
private void OnButtonDown()
{
- if (_mapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (_mapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
@@ -85,7 +85,7 @@
private void OnButtonUp()
{
- if (_mapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (_mapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorHoverArea.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorHoverArea.cs
index 9e505f2..2706b34 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorHoverArea.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorHoverArea.cs
@@ -86,7 +86,7 @@
private void OnMouseEnter()
{
- if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
@@ -99,7 +99,7 @@
private void OnMouseExit()
{
- if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Door)
+ if (MapEditorToolsPanel.EditorMap.Instance.MouseType != EditorTileMap.MouseButtonType.Edit)
{
return;
}
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MapEditorToolsPanel.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MapEditorToolsPanel.cs
index 727c2ef..ed3d20c 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MapEditorToolsPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MapEditorToolsPanel.cs
@@ -9,8 +9,11 @@
{
public class ToolBtnData
{
+ //是否可以选中
public bool CanSelect = false;
+ //工具图标
public string Icon;
+ //点击时回调
public Action OnClick;
public ToolBtnData(bool canSelect, string icon, Action onClick)
@@ -34,16 +37,19 @@
///
/// 所属编辑器Tile对象
///
- public MapEditor.MapEditor.TileMap EditorMap { get; set; }
+ public MapEditor.MapEditor.TileMap EditorMap { get; private set; }
private List _doorTools = new List();
private UiGrid _toolGrid;
//当前预设的所有标记
private Dictionary _currMarkToolsMap = new Dictionary();
private EventFactory _eventFactory;
+ private int _editToolIndex;
public override void OnCreateUi()
{
+ EditorMap = ((MapEditorPanel)ParentUi).S_TileMap;
+
S_N_HoverArea.Instance.Init(this, DoorDirection.N);
S_S_HoverArea.Instance.Init(this, DoorDirection.S);
S_W_HoverArea.Instance.Init(this, DoorDirection.W);
@@ -68,11 +74,12 @@
{
EventManager.EmitEvent(EventEnum.OnSelectRectTool);
}));
- //编辑门区域按钮
+ //编辑攻击按钮
_toolGrid.Add(new ToolBtnData(true, ResourcePath.resource_sprite_ui_commonIcon_DoorTool_png, () =>
{
- EventManager.EmitEvent(EventEnum.OnSelectDoorTool);
+ EventManager.EmitEvent(EventEnum.OnSelectEditTool);
}));
+ _editToolIndex = _toolGrid.Count - 1;
//聚焦按钮
_toolGrid.Add(new ToolBtnData(false, ResourcePath.resource_sprite_ui_commonIcon_CenterTool_png, () =>
{
@@ -105,7 +112,7 @@
public override void Process(float delta)
{
S_HoverPreviewRoot.Instance.Visible = ActiveHoverArea != null && !DoorHoverArea.IsDrag;
- if (EditorMap.Instance.MouseType == EditorTileMap.MouseButtonType.Door)
+ if (EditorMap.Instance.MouseType == EditorTileMap.MouseButtonType.Edit)
{
S_ToolRoot.Instance.Modulate = new Color(1, 1, 1, 1);
}
@@ -166,6 +173,12 @@
SetActiveMark(markTemplate.Instance);
}
}
+
+ //选中编辑工具
+ if (_toolGrid.SelectIndex != _editToolIndex)
+ {
+ _toolGrid.Click(_editToolIndex);
+ }
}
}
@@ -242,14 +255,14 @@
return;
}
- if (ActiveMark != null)
+ if (ActiveMark != null) //取消选中上一个
{
- ActiveMark.Modulate = Colors.White;
+ ActiveMark.OnUnSelect();
}
ActiveMark = markTool;
- if (markTool != null)
+ if (markTool != null) //选中当前
{
- markTool.Modulate = Colors.Green;
+ ActiveMark.OnSelect();
EventManager.EmitEvent(EventEnum.OnSelectMark, markTool.MarkInfo);
}
else
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkAreaTool.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkAreaTool.cs
index 047e2cb..b55ac19 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkAreaTool.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkAreaTool.cs
@@ -1,4 +1,5 @@
using Godot;
+using UI.MapEditor;
using Color = Godot.Color;
namespace UI.MapEditorTools;
@@ -142,47 +143,51 @@
_mouseInRB = false;
var flag = false;
- var mousePosition = GetLocalMousePosition();
- //判断鼠标是否在点上
- if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetLeftTopRect()))
+ //必须要选中
+ if (_toolRoot.UiPanel.EditorMap.Instance.MouseType == EditorTileMap.MouseButtonType.Edit)
{
- _mouseInLT = true;
- flag = true;
- }
- else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetRightTopRect()))
- {
- _mouseInRT = true;
- flag = true;
- }
- else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetLeftBottomRect()))
- {
- _mouseInLB = true;
- flag = true;
- }
- else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetRightBottomRect()))
- {
- _mouseInRB = true;
- flag = true;
- }
- else if (Utils.IsPositionInRect(mousePosition, GetLeftRect()))
- {
- _mouseInL = true;
- flag = true;
- }
- else if (Utils.IsPositionInRect(mousePosition, GetRightRect()))
- {
- _mouseInR = true;
- flag = true;
- }
- else if (Utils.IsPositionInRect(mousePosition, GetTopRect()))
- {
- _mouseInT = true;
- flag = true;
- }
- else if (Utils.IsPositionInRect(mousePosition, GetBottomRect()))
- {
- _mouseInB = true;
- flag = true;
+ var mousePosition = GetLocalMousePosition();
+ //判断鼠标是否在点上
+ if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetLeftTopRect()))
+ {
+ _mouseInLT = true;
+ flag = true;
+ }
+ else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetRightTopRect()))
+ {
+ _mouseInRT = true;
+ flag = true;
+ }
+ else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetLeftBottomRect()))
+ {
+ _mouseInLB = true;
+ flag = true;
+ }
+ else if (_showCornerBlock && Utils.IsPositionInRect(mousePosition, GetRightBottomRect()))
+ {
+ _mouseInRB = true;
+ flag = true;
+ }
+ else if (Utils.IsPositionInRect(mousePosition, GetLeftRect()))
+ {
+ _mouseInL = true;
+ flag = true;
+ }
+ else if (Utils.IsPositionInRect(mousePosition, GetRightRect()))
+ {
+ _mouseInR = true;
+ flag = true;
+ }
+ else if (Utils.IsPositionInRect(mousePosition, GetTopRect()))
+ {
+ _mouseInT = true;
+ flag = true;
+ }
+ else if (Utils.IsPositionInRect(mousePosition, GetBottomRect()))
+ {
+ _mouseInB = true;
+ flag = true;
+ }
}
if (flag)
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkTool.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkTool.cs
index fb894b4..ce482f4 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkTool.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/MarkTool.cs
@@ -1,4 +1,5 @@
using Godot;
+using UI.MapEditor;
namespace UI.MapEditorTools;
@@ -22,7 +23,7 @@
private bool _isDown;
private Vector2 _offset;
private MarkAreaTool _markAreaToolUp;
-
+
public void SetUiNode(IUiNode uiNode)
{
_toolNode = (MapEditorTools.MarkTemplate)uiNode;
@@ -39,39 +40,37 @@
{
if (_toolNode != null && MarkInfo != null)
{
- if (_enter)
+ if (_isDown)
{
- if (_isDown)
+ //松开鼠标或者在拖拽区域
+ if (!Input.IsMouseButtonPressed(MouseButton.Left) || _markAreaToolUp.IsDrag)
{
- //松开鼠标或者在拖拽区域
- if (!Input.IsMouseButtonPressed(MouseButton.Left) || _markAreaToolUp.IsDrag)
- {
- _isDown = false;
- IsDrag = false;
- }
+ _isDown = false;
+ IsDrag = false;
}
- else if (!_isDown)
+ }
+ else if (_enter && !_isDown)
+ {
+ //判断是否可以选中
+ var activeMark = _toolNode.UiPanel.ActiveMark;
+ if ((activeMark == null || (!activeMark.IsDrag && !activeMark._markAreaToolUp.IsDrag)) &&
+ !_markAreaToolUp.IsDrag && Input.IsMouseButtonPressed(MouseButton.Left) &&
+ _toolNode.UiPanel.EditorMap.Instance.MouseType == EditorTileMap.MouseButtonType.Edit)
{
- //按下鼠标
- var activeMark = _toolNode.UiPanel.ActiveMark;
- if ((activeMark == null || (!activeMark.IsDrag && !activeMark._markAreaToolUp.IsDrag))
- && !_markAreaToolUp.IsDrag && Input.IsMouseButtonPressed(MouseButton.Left))
+ _isDown = true;
+ if (_toolNode.UiPanel.ActiveMark != this)
{
- _isDown = true;
- if (_toolNode.UiPanel.ActiveMark != this)
- {
- IsDrag = false;
- _toolNode.UiPanel.SetActiveMark(this);
- }
- else
- {
- _offset = GlobalPosition - GetGlobalMousePosition();
- IsDrag = true;
- }
+ IsDrag = false;
+ _toolNode.UiPanel.SetActiveMark(this);
+ }
+ else
+ {
+ _offset = GlobalPosition - GetGlobalMousePosition();
+ IsDrag = true;
}
}
}
-
+
//拖拽中
if (IsDrag && _toolNode.UiPanel.ActiveMark == this)
{
@@ -120,4 +119,22 @@
DrawRect(new Rect2(-size / 2 + Size / 2, size.X, size.Y), new Color(1, 1, 1, 0.3f), false, 1);
}
}
+
+ ///
+ /// 选中标记
+ ///
+ public void OnSelect()
+ {
+ var a = Modulate.A;
+ Modulate = new Color(0, 1, 0, a);
+ }
+
+ ///
+ /// 取消选中标记
+ ///
+ public void OnUnSelect()
+ {
+ var a = Modulate.A;
+ Modulate = new Color(1, 1, 1, a);
+ }
}
\ No newline at end of file