diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
index c2ac62a..6921006 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragArea.cs
@@ -12,6 +12,11 @@
//错误时的颜色
private static Color _errorColor = new Color(1, 0, 0, 0.1882353F);
+ ///
+ /// 朝向
+ ///
+ public DoorDirection Direction { get; private set; }
+
private MapEditorTools.DoorToolTemplate _node;
private Vector2 _startTempPos;
private Vector2 _endTempPos;
@@ -23,24 +28,56 @@
private bool _canComment = true;
//开始拖拽时的区域
private Vector2I _startDragRange;
-
+ //原始缩放
+ private Vector2 _originScale;
+
public void SetDoorDragAreaNode(MapEditorTools.DoorToolTemplate node)
{
_node = node;
+ _originScale = Scale;
_defaultColor = _node.L_DoorArea.Instance.Color;
_node.L_StartBtn.Instance.DragEvent += OnStartAreaDrag;
_node.L_EndBtn.Instance.DragEvent += OnEndAreaDrag;
SetDoorAreaSize(GameConfig.TileCellSize * 4);
+ SetDoorAreaDirection(DoorDirection.N);
}
///
+ /// 设置门区域的方向
+ ///
+ public void SetDoorAreaDirection(DoorDirection direction)
+ {
+ Direction = direction;
+ if (direction == DoorDirection.N)
+ {
+ _originScale = new Vector2(1, 1);
+ RotationDegrees = 0;
+ }
+ else if (direction == DoorDirection.E)
+ {
+ _originScale = new Vector2(1, 1);
+ RotationDegrees = 90;
+ }
+ else if (direction == DoorDirection.S)
+ {
+ _originScale = new Vector2(-1, 1);
+ RotationDegrees = 180;
+ }
+ else
+ {
+ _originScale = new Vector2(-1, 1);
+ RotationDegrees = 270;
+ }
+ }
+
+ ///
/// 设置位置和缩放, 用于跟随地图
///
public void SetDoorAreaTransform(Vector2 pos, Vector2 scale)
{
Position = pos;
- Scale = scale;
+ Scale = _originScale * scale;
}
///
diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
index fa65c61..a3aa53c 100644
--- a/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
+++ b/DungeonShooting_Godot/src/game/ui/mapEditorTools/DoorDragButton.cs
@@ -31,6 +31,20 @@
if (DragEvent != null)
{
var offset = Utils.Adsorption((GetGlobalMousePosition() - _startPos) / _parent.Scale, _stepValue);
+ //处理朝向问题
+ if (_parent.Direction == DoorDirection.E)
+ {
+ offset = new Vector2(offset.Y, offset.X);
+ }
+ else if (_parent.Direction == DoorDirection.S)
+ {
+ offset = new Vector2(-offset.X, offset.Y);
+ }
+ else if (_parent.Direction == DoorDirection.W)
+ {
+ offset = new Vector2(offset.Y, -offset.X);
+ }
+
if (offset != _prevPos)
{
_prevPos = offset;