diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index c6253cf..3a53575 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -192,6 +192,11 @@ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194326,"key_label":0,"unicode":0,"echo":false,"script":null) ] } +menu={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"echo":false,"script":null) +] +} [layer_names] diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs index 828fae4..36fa126 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs @@ -67,7 +67,7 @@ /// /// 连接过道使用预览图, 用于小地图 /// - public Sprite2D AislePreviewSprite; + public TextureRect AislePreviewSprite; /// /// 门实例 diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index b293ed8..3324738 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -128,7 +128,7 @@ /// /// 房间预览图, 用于小地图 /// - public Sprite2D PreviewSprite { get; set; } + public TextureRect PreviewSprite { get; set; } public bool IsDestroyed { get; private set; } diff --git a/DungeonShooting_Godot/src/game/manager/InputManager.cs b/DungeonShooting_Godot/src/game/manager/InputManager.cs index 0541530..5442ed0 100644 --- a/DungeonShooting_Godot/src/game/manager/InputManager.cs +++ b/DungeonShooting_Godot/src/game/manager/InputManager.cs @@ -75,6 +75,11 @@ /// 是否按下打开地图按钮, 键鼠: 键盘Ctrl /// public static bool Map { get; private set; } + + /// + /// 菜单键, 键鼠: esc + /// + public static bool Menu { get; private set; } /// /// 更新输入管理器 @@ -99,5 +104,6 @@ RemoveProp = Input.IsActionJustPressed("removeProp"); ExchangeProp = Input.IsActionJustPressed("exchangeProp"); Map = Input.IsActionPressed("map"); + Menu = Input.IsActionJustPressed("menu"); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index daf3368..8565c8a 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -164,7 +164,7 @@ } //暂停游戏 - if (Input.IsActionJustPressed("ui_cancel")) + if (InputManager.Menu) { World.Pause = true; //鼠标改为Ui鼠标 @@ -599,11 +599,11 @@ private void CreatePreviewSprite(RoomInfo roomInfo) { //房间区域 - var sprite = new Sprite2D(); - sprite.Centered = false; + var sprite = new TextureRect(); + //sprite.Centered = false; sprite.Texture = roomInfo.PreviewTexture; sprite.Position = roomInfo.Position; - var material = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); + var material = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres, false); material.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); material.SetShaderParameter("scale", 0.5f); sprite.Material = material; @@ -616,8 +616,8 @@ { if (doorInfo.IsForward) { - var aisleSprite = new Sprite2D(); - aisleSprite.Centered = false; + var aisleSprite = new TextureRect(); + //aisleSprite.Centered = false; aisleSprite.Texture = doorInfo.AislePreviewTexture; //调整过道预览位置 @@ -696,7 +696,7 @@ } } - var aisleSpriteMaterial = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); + var aisleSpriteMaterial = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres, false); aisleSpriteMaterial.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); aisleSpriteMaterial.SetShaderParameter("scale", 0.5f); aisleSprite.Material = aisleSpriteMaterial; diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 6e3bdd7..b5dfb9b 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -18,7 +18,13 @@ private Stack _spriteStack = new Stack(); //是否放大地图 private bool _isMagnifyMap = false; + private DragBinder _dragBinder; + //放大地图后拖拽的偏移 + private Vector2 _mapOffset; + //放大地图后鼠标悬停的房间 + private RoomInfo _mouseHoverRoom; + private Color _originOutlineColor; public override void OnCreateUi() { @@ -48,9 +54,12 @@ //按下地图按键 if (InputManager.Map && !_isMagnifyMap) { - World.Current.Pause = true; - _isMagnifyMap = true; - MagnifyMap(); + if (UiManager.GetUiInstanceCount(UiManager.UiName.PauseMenu) == 0) + { + World.Current.Pause = true; + _isMagnifyMap = true; + MagnifyMap(); + } } else if (!InputManager.Map && _isMagnifyMap) { @@ -129,7 +138,15 @@ } //更新地图中心点位置 - S_Root.Instance.Position = CalcRootPosition(Player.Current.Position); + if (!_isMagnifyMap) + { + S_Root.Instance.Position = CalcRootPosition(Player.Current.Position); + } + else + { + S_Root.Instance.Position = CalcRootPosition(Player.Current.Position) + _mapOffset; + S_Mark.Instance.Position = S_DrawContainer.Instance.Size / 2 + _mapOffset; + } } private void OnDrawContainerResized() @@ -140,33 +157,48 @@ //放大小地图 private void MagnifyMap() { + GameApplication.Instance.Cursor.SetGuiMode(true); 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; - + _mapOffset = Vector2.Zero; + _dragBinder = DragUiManager.BindDrag(S_DrawContainer.Instance, (state, delta) => { - //S_DrawContainer.Instance.Position += delta; - Debug.Log($"state: {state}, delta: {delta}"); + if (state == DragState.DragMove) + { + _mapOffset += delta; + } }); } //还原小地图 private void ResetMap() { + GameApplication.Instance.Cursor.SetGuiMode(false); 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; + ResetOutlineColor(); if (_dragBinder != null) { _dragBinder.UnBind(); } } + + private void ResetOutlineColor() + { + if (_mouseHoverRoom != null) + { + ((ShaderMaterial)_mouseHoverRoom.PreviewSprite.Material).SetShaderParameter("outline_color", _originOutlineColor); + _mouseHoverRoom = null; + } + } //初始化小地图 private void InitMap() @@ -174,9 +206,21 @@ var startRoom = GameApplication.Instance.DungeonManager.StartRoomInfo; startRoom.EachRoom(roomInfo => { + //房间 roomInfo.PreviewSprite.Visible = false; S_Root.AddChild(roomInfo.PreviewSprite); + roomInfo.PreviewSprite.MouseEntered += () => + { + ResetOutlineColor(); + _mouseHoverRoom = roomInfo; + var shaderMaterial = (ShaderMaterial)roomInfo.PreviewSprite.Material; + _originOutlineColor = shaderMaterial.GetShaderParameter("outline_color").AsColor(); + shaderMaterial.SetShaderParameter("outline_color", new Color(0, 1, 0, 0.9f)); + }; + roomInfo.PreviewSprite.MouseExited += ResetOutlineColor; + + //过道 if (roomInfo.Doors != null) { foreach (var roomInfoDoor in roomInfo.Doors)