diff --git a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn
index 3972340..3e0a791 100644
--- a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn
+++ b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn
@@ -1,7 +1,7 @@
[gd_scene load_steps=5 format=3 uid="uid://bmj3p25gwpqpn"]
[ext_resource type="Script" path="res://src/game/ui/roomMap/RoomMapPanel.cs" id="1_ng7b3"]
-[ext_resource type="Texture2D" uid="uid://k621mhhkg65f" path="res://resource/sprite/ui/roomUI/MapBar.png" id="2_m52os"]
+[ext_resource type="Texture2D" uid="uid://k621mhhkg65f" path="res://resource/sprite/ui/roomMap/MapBar.png" id="2_m52os"]
[ext_resource type="Texture2D" uid="uid://0878uloew5jo" path="res://resource/sprite/ui/commonIcon/Block.png" id="3_el2ne"]
[ext_resource type="Texture2D" uid="uid://cw702ostmv2am" path="res://resource/sprite/role/role0001/Role0001_head.png" id="4_6wquw"]
@@ -15,14 +15,13 @@
script = ExtResource("1_ng7b3")
[node name="Bg" type="ColorRect" parent="."]
-visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
-color = Color(0, 0, 0, 0.196078)
+color = Color(0, 0, 0, 0.588235)
[node name="MapBar" type="NinePatchRect" parent="."]
layout_mode = 1
@@ -31,15 +30,14 @@
anchor_right = 1.0
offset_left = -275.0
offset_top = 20.0
-offset_right = -211.0
-offset_bottom = 84.0
+offset_right = -19.0
+offset_bottom = 276.0
grow_horizontal = 0
-scale = Vector2(4, 4)
texture = ExtResource("2_m52os")
-patch_margin_left = 2
-patch_margin_top = 2
-patch_margin_right = 2
-patch_margin_bottom = 2
+patch_margin_left = 4
+patch_margin_top = 4
+patch_margin_right = 4
+patch_margin_bottom = 4
[node name="DrawContainer" type="TextureRect" parent="MapBar"]
clip_children = 1
@@ -57,9 +55,26 @@
expand_mode = 1
[node name="Root" type="Node2D" parent="MapBar/DrawContainer"]
-scale = Vector2(1.5, 1.5)
+scale = Vector2(6, 6)
[node name="Mark" type="Sprite2D" parent="MapBar/DrawContainer"]
-position = Vector2(32, 32)
-scale = Vector2(0.5, 0.5)
+position = Vector2(128, 128)
+scale = Vector2(2, 2)
texture = ExtResource("4_6wquw")
+
+[node name="MagnifyMapBar" type="NinePatchRect" parent="."]
+layout_mode = 1
+anchors_preset = 15
+anchor_right = 1.0
+anchor_bottom = 1.0
+offset_left = 390.0
+offset_top = 131.0
+offset_right = -390.0
+offset_bottom = -131.0
+grow_horizontal = 2
+grow_vertical = 2
+texture = ExtResource("2_m52os")
+patch_margin_left = 4
+patch_margin_top = 4
+patch_margin_right = 4
+patch_margin_bottom = 4
diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png b/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png
new file mode 100644
index 0000000..2413168
--- /dev/null
+++ b/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png
Binary files differ
diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png.import b/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png.import
new file mode 100644
index 0000000..850a99b
--- /dev/null
+++ b/DungeonShooting_Godot/resource/sprite/ui/roomMap/MapBar.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://k621mhhkg65f"
+path="res://.godot/imported/MapBar.png-b48b0548dd5961c6b8cbfded48cd342f.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://resource/sprite/ui/roomMap/MapBar.png"
+dest_files=["res://.godot/imported/MapBar.png-b48b0548dd5961c6b8cbfded48cd342f.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png b/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png
deleted file mode 100644
index fba3dac..0000000
--- a/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png
+++ /dev/null
Binary files differ
diff --git a/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png.import b/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png.import
deleted file mode 100644
index 38c02ed..0000000
--- a/DungeonShooting_Godot/resource/sprite/ui/roomUI/MapBar.png.import
+++ /dev/null
@@ -1,34 +0,0 @@
-[remap]
-
-importer="texture"
-type="CompressedTexture2D"
-uid="uid://k621mhhkg65f"
-path="res://.godot/imported/MapBar.png-b929285ef9227704736eaf783aa026b9.ctex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://resource/sprite/ui/roomUI/MapBar.png"
-dest_files=["res://.godot/imported/MapBar.png-b929285ef9227704736eaf783aa026b9.ctex"]
-
-[params]
-
-compress/mode=0
-compress/high_quality=false
-compress/lossy_quality=0.7
-compress/hdr_compression=1
-compress/normal_map=0
-compress/channel_pack=0
-mipmaps/generate=false
-mipmaps/limit=-1
-roughness/mode=0
-roughness/src_normal=""
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/normal_map_invert_y=false
-process/hdr_as_srgb=false
-process/hdr_clamp_exposure=false
-process/size_limit=0
-detect_3d/compress_to=1
diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs
index c2014f7..3f57200 100644
--- a/DungeonShooting_Godot/src/game/GameApplication.cs
+++ b/DungeonShooting_Godot/src/game/GameApplication.cs
@@ -106,7 +106,7 @@
//随机化种子
//GD.Randomize();
//固定帧率
- //Engine.MaxFps = TargetFps;
+ Engine.MaxFps = TargetFps;
//调试绘制开关
ActivityObject.IsDebug = false;
//Engine.TimeScale = 0.2f;
@@ -141,6 +141,7 @@
var newDelta = (float)delta;
InputManager.Update(newDelta);
SoundManager.Update(newDelta);
+ DragUiManager.Update(newDelta);
//协程更新
ProxyCoroutineHandler.ProxyUpdateCoroutine(ref _coroutineList, newDelta);
diff --git a/DungeonShooting_Godot/src/game/activity/role/player/PlayerRoleState.cs b/DungeonShooting_Godot/src/game/activity/role/player/PlayerRoleState.cs
index ba70cce..f52b21d 100644
--- a/DungeonShooting_Godot/src/game/activity/role/player/PlayerRoleState.cs
+++ b/DungeonShooting_Godot/src/game/activity/role/player/PlayerRoleState.cs
@@ -14,5 +14,5 @@
///
/// 翻滚冷却时间
///
- public float RollCoolingTime = 0.5f;
+ public float RollCoolingTime = 0.4f;
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/data/DragBinder.cs b/DungeonShooting_Godot/src/game/data/DragBinder.cs
new file mode 100644
index 0000000..4622dea
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/data/DragBinder.cs
@@ -0,0 +1,30 @@
+
+using System;
+using Godot;
+
+///
+/// 拖拽绑定数据对象, 通过 DragUiManager 创建
+///
+public class DragBinder
+{
+ public Control Control;
+ public bool MouseEntered;
+ public bool Dragging;
+ public Vector2 PrevPosition;
+ public Action Callback;
+
+ public void OnMouseEntered()
+ {
+ MouseEntered = true;
+ }
+
+ public void OnMouseExited()
+ {
+ MouseEntered = false;
+ }
+
+ public void UnBind()
+ {
+ DragUiManager.UnBindDrag(this);
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/manager/DragUiManager.cs b/DungeonShooting_Godot/src/game/manager/DragUiManager.cs
new file mode 100644
index 0000000..e6f25ec
--- /dev/null
+++ b/DungeonShooting_Godot/src/game/manager/DragUiManager.cs
@@ -0,0 +1,85 @@
+using System;
+using System.Collections.Generic;
+using Godot;
+
+public static class DragUiManager
+{
+ private static readonly List _list = new List();
+ private static readonly List _removeList = new List();
+ private static readonly List _addList = new List();
+
+ public static DragBinder BindDrag(Control control, Action callback)
+ {
+ var binder = new DragBinder();
+ binder.Control = control;
+ control.MouseEntered += binder.OnMouseEntered;
+ control.MouseExited += binder.OnMouseExited;
+ binder.Callback = callback;
+ _addList.Add(binder);
+ return binder;
+ }
+
+ public static void UnBindDrag(DragBinder binder)
+ {
+ if (!_removeList.Contains(binder))
+ {
+ _removeList.Add(binder);
+ }
+ }
+
+ public static void Update(float delta)
+ {
+ //更新拖拽位置
+ if (_list.Count > 0)
+ {
+ foreach (var dragBinder in _list)
+ {
+ if (dragBinder.Dragging && !Input.IsMouseButtonPressed(MouseButton.Left)) //松开鼠标, 结束拖拽
+ {
+ dragBinder.Dragging = false;
+ dragBinder.Callback(DragState.DragEnd, Vector2.Zero);
+ }
+ else if (!dragBinder.Dragging) //开始拖拽
+ {
+ if (dragBinder.MouseEntered && Input.IsMouseButtonPressed(MouseButton.Left))
+ {
+ dragBinder.Dragging = true;
+ dragBinder.PrevPosition = dragBinder.Control.GetGlobalMousePosition();
+ dragBinder.Callback(DragState.DragStart, Vector2.Zero);
+ }
+ }
+ else //拖拽更新
+ {
+ var mousePos = dragBinder.Control.GetGlobalMousePosition();
+ if (mousePos != dragBinder.PrevPosition)
+ {
+ var deltaPosition = mousePos - dragBinder.PrevPosition;
+ dragBinder.PrevPosition = mousePos;
+ dragBinder.Callback(DragState.DragMove, deltaPosition);
+ }
+ }
+ }
+ }
+
+ //移除绑定
+ if (_removeList.Count > 0)
+ {
+ foreach (var binder in _removeList)
+ {
+ if (_list.Remove(binder))
+ {
+ binder.Control.MouseEntered -= binder.OnMouseEntered;
+ binder.Control.MouseExited -= binder.OnMouseExited;
+ }
+ }
+ _removeList.Clear();
+ }
+
+ //添加绑定
+ if (_addList.Count > 0)
+ {
+ _list.AddRange(_addList);
+ _addList.Clear();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/PolygonOutline.cs b/DungeonShooting_Godot/src/game/ui/roomMap/PolygonOutline.cs
deleted file mode 100644
index 1cde296..0000000
--- a/DungeonShooting_Godot/src/game/ui/roomMap/PolygonOutline.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Godot;
-
-namespace UI.RoomMap;
-
-public partial class PolygonOutline : Polygon2D
-{
- private Vector2[] _points;
-
- public override void _Ready()
- {
- Color = new Color(0, 0, 0, 0.5882353F);
- }
-
- public void SetPoints(Vector2[] points)
- {
- _points = points;
- Polygon = points;
- }
-
- public override void _Draw()
- {
- for (var i = 0; i < _points.Length; i++)
- {
- DrawLine(_points[i], _points[(i + 1) % _points.Length], Colors.Red, 6f);
- }
- }
-}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMap.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMap.cs
index f1deb43..737698b 100644
--- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMap.cs
+++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMap.cs
@@ -31,6 +31,19 @@
}
private MapBar _L_MapBar;
+ ///
+ /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: RoomMap.MagnifyMapBar
+ ///
+ public MagnifyMapBar L_MagnifyMapBar
+ {
+ get
+ {
+ if (_L_MagnifyMapBar == null) _L_MagnifyMapBar = new MagnifyMapBar((RoomMapPanel)this, GetNode("MagnifyMapBar"));
+ return _L_MagnifyMapBar;
+ }
+ }
+ private MagnifyMapBar _L_MagnifyMapBar;
+
public RoomMap() : base(nameof(RoomMap))
{
@@ -125,6 +138,15 @@
public override MapBar Clone() => new (UiPanel, (Godot.NinePatchRect)Instance.Duplicate());
}
+ ///
+ /// 类型: , 路径: RoomMap.MagnifyMapBar
+ ///
+ public class MagnifyMapBar : UiNode
+ {
+ public MagnifyMapBar(RoomMapPanel uiPanel, Godot.NinePatchRect node) : base(uiPanel, node) { }
+ public override MagnifyMapBar Clone() => new (UiPanel, (Godot.NinePatchRect)Instance.Duplicate());
+ }
+
///
/// 场景中唯一名称的节点, 节点类型: , 节点路径: RoomMap.Bg
@@ -151,4 +173,9 @@
///
public MapBar S_MapBar => L_MapBar;
+ ///
+ /// 场景中唯一名称的节点, 节点类型: , 节点路径: RoomMap.MagnifyMapBar
+ ///
+ public MagnifyMapBar S_MagnifyMapBar => L_MagnifyMapBar;
+
}
diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs
index ad63085..6e3bdd7 100644
--- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs
@@ -4,39 +4,60 @@
namespace UI.RoomMap;
+///
+/// 房间的小地图
+///
public partial class RoomMapPanel : RoomMap
{
private EventFactory _factory = EventManager.CreateEventFactory();
+ //需要刷新的问号的房间队列
private List _needRefresh = new List();
+ //正在使用的敌人标记列表
private List _enemySpriteList = new List();
+ //已经回收的敌人标记
private Stack _spriteStack = new Stack();
+ //是否放大地图
+ private bool _isMagnifyMap = false;
+ private DragBinder _dragBinder;
public override void OnCreateUi()
{
+ _ = S_Mark;
+ S_Bg.Instance.Visible = false;
+ S_MagnifyMapBar.Instance.Visible = false;
InitMap();
_factory.AddEventListener(EventEnum.OnPlayerFirstEnterRoom, OnPlayerFirstEnterRoom);
_factory.AddEventListener(EventEnum.OnPlayerFirstEnterAisle, OnPlayerFirstEnterAisle);
+
+ S_DrawContainer.Instance.Resized += OnDrawContainerResized;
}
public override void OnDestroyUi()
{
_factory.RemoveAllEventListener();
+
+ if (_dragBinder != null)
+ {
+ _dragBinder.UnBind();
+ }
}
public override void Process(float delta)
{
- // //按下地图按键
- // if (InputManager.Map && !S_RoomMap.Instance.IsOpen)
- // {
- // World.Current.Pause = true;
- // S_RoomMap.Instance.ShowUi();
- // }
- // else if (!InputManager.Map && S_RoomMap.Instance.IsOpen)
- // {
- // S_RoomMap.Instance.HideUi();
- // World.Current.Pause = false;
- // }
+ //按下地图按键
+ if (InputManager.Map && !_isMagnifyMap)
+ {
+ World.Current.Pause = true;
+ _isMagnifyMap = true;
+ MagnifyMap();
+ }
+ else if (!InputManager.Map && _isMagnifyMap)
+ {
+ ResetMap();
+ _isMagnifyMap = false;
+ World.Current.Pause = false;
+ }
//更新敌人位置
if (World.Current != null)
@@ -110,6 +131,42 @@
//更新地图中心点位置
S_Root.Instance.Position = CalcRootPosition(Player.Current.Position);
}
+
+ private void OnDrawContainerResized()
+ {
+ S_Mark.Instance.Position = S_DrawContainer.Instance.Size / 2;
+ }
+
+ //放大小地图
+ private void MagnifyMap()
+ {
+ S_DrawContainer.Reparent(S_MagnifyMapBar);
+ S_DrawContainer.Instance.Position = new Vector2(1, 1);
+ S_Bg.Instance.Visible = true;
+ S_MagnifyMapBar.Instance.Visible = true;
+ S_MapBar.Instance.Visible = false;
+
+ _dragBinder = DragUiManager.BindDrag(S_DrawContainer.Instance, (state, delta) =>
+ {
+ //S_DrawContainer.Instance.Position += delta;
+ Debug.Log($"state: {state}, delta: {delta}");
+ });
+ }
+
+ //还原小地图
+ private void ResetMap()
+ {
+ S_DrawContainer.Reparent(S_MapBar);
+ S_DrawContainer.Instance.Position = new Vector2(1, 1);
+ S_Bg.Instance.Visible = false;
+ S_MagnifyMapBar.Instance.Visible = false;
+ S_MapBar.Instance.Visible = true;
+
+ if (_dragBinder != null)
+ {
+ _dragBinder.UnBind();
+ }
+ }
//初始化小地图
private void InitMap()
@@ -157,6 +214,7 @@
RefreshUnknownSprite(roomDoorInfo.ConnectDoor);
}
+ //进入刷新问号队列
private void RefreshUnknownSprite(RoomDoorInfo roomDoorInfo)
{
if (!_needRefresh.Contains(roomDoorInfo))
@@ -165,6 +223,7 @@
}
}
+ //刷新问号
private void HandlerRefreshUnknownSprite(RoomDoorInfo roomDoorInfo)
{
//是否探索房间