diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index d4bfee3..dd65ab8 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -8,4 +8,10 @@ + + + + + + \ No newline at end of file diff --git a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn index d2f68b0..853dfcf 100644 --- a/DungeonShooting_Godot/prefab/ui/RoomMap.tscn +++ b/DungeonShooting_Godot/prefab/ui/RoomMap.tscn @@ -3,7 +3,7 @@ [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://0878uloew5jo" path="res://resource/sprite/ui/commonIcon/Block.png" id="3_el2ne"] -[ext_resource type="Texture2D" uid="uid://n4atvj5fkcpg" path="res://resource/sprite/ui/commonIcon/Add.png" id="5_4sud2"] +[ext_resource type="Texture2D" uid="uid://cw702ostmv2am" path="res://resource/sprite/role/role0001/Role0001_head.png" id="4_6wquw"] [node name="RoomMap" type="Control"] layout_mode = 3 @@ -60,7 +60,6 @@ scale = Vector2(1.5, 1.5) [node name="Mark" type="Sprite2D" parent="MapBar/DrawContainer"] -modulate = Color(0.219608, 1, 0, 1) position = Vector2(28, 28) -scale = Vector2(0.1, 0.1) -texture = ExtResource("5_4sud2") +scale = Vector2(0.5, 0.5) +texture = ExtResource("4_6wquw") diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png b/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png new file mode 100644 index 0000000..fd0f206 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png.import new file mode 100644 index 0000000..4526cc4 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/Role0001_head.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cw702ostmv2am" +path="res://.godot/imported/Role0001_head.png-9e4bb55990b7b54630895db4565f621f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/role/role0001/Role0001_head.png" +dest_files=["res://.godot/imported/Role0001_head.png-9e4bb55990b7b54630895db4565f621f.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/commonIcon/Unknown.png b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Unknown.png new file mode 100644 index 0000000..a50162f --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Unknown.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Unknown.png.import b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Unknown.png.import new file mode 100644 index 0000000..3f9b7af --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/ui/commonIcon/Unknown.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://w54se0667dqv" +path="res://.godot/imported/Unknown.png-49f545b95bd2713bdaacd2b4caa7b3a1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/ui/commonIcon/Unknown.png" +dest_files=["res://.godot/imported/Unknown.png-49f545b95bd2713bdaacd2b4caa7b3a1.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/framework/map/fog/FogMaskHandler.cs b/DungeonShooting_Godot/src/framework/map/fog/FogMaskHandler.cs index cfa21e4..31504dc 100644 --- a/DungeonShooting_Godot/src/framework/map/fog/FogMaskHandler.cs +++ b/DungeonShooting_Godot/src/framework/map/fog/FogMaskHandler.cs @@ -96,6 +96,9 @@ fogMask.IsExplored = true; fogMask.TransitionAlpha(0, 1); + //小地图亮起该房间 + roomInfo.PreviewSprite.Visible = true; + //刷新预览区域 foreach (var roomInfoDoor in roomInfo.Doors) { @@ -142,6 +145,9 @@ var connectDoor = doorInfo.ConnectDoor; if (!fogMask.IsExplored) //未探索该区域 { + //小地图亮起该过道 + doorInfo.AislePreviewSprite.Visible = true; + fogMask.IsExplored = true; doorInfo.PreviewAisleFogMask.IsExplored = true; doorInfo.PreviewRoomFogMask.IsExplored = true; diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs index f30411f..56ab624 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomDoorInfo.cs @@ -60,11 +60,16 @@ public NavigationPolygonData AisleNavigation; /// - /// 连接过道使用预览纹理 + /// 连接过道使用预览纹理, 用于小地图 /// public ImageTexture AislePreviewTexture; /// + /// 连接过道使用预览图, 用于小地图 + /// + public Sprite2D AislePreviewSprite; + + /// /// 门实例 /// public RoomDoor Door; @@ -288,5 +293,10 @@ { AislePreviewTexture.Dispose(); } + + if (AislePreviewSprite != null) + { + AislePreviewSprite.QueueFree(); + } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index 698bccc..b293ed8 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -121,10 +121,15 @@ public Dictionary MarkTargetPosition { get; private set; } = new Dictionary(); /// - /// 房间预览图, 用于小地图 + /// 房间预览纹理, 用于小地图 /// public ImageTexture PreviewTexture { get; set; } + /// + /// 房间预览图, 用于小地图 + /// + public Sprite2D PreviewSprite { get; set; } + public bool IsDestroyed { get; private set; } private bool _openDoorFlag = true; @@ -381,6 +386,11 @@ { PreviewTexture.Dispose(); } + + if (PreviewSprite != null) + { + PreviewSprite.QueueFree(); + } MarkTargetPosition.Clear(); } diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index e63703d..fa58a54 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -384,6 +384,8 @@ CreateRoomLiquidCanvas(roomInfo); //创建迷雾遮罩 CreateRoomFogMask(roomInfo); + //创建房间/过道预览sprite + CreatePreviewSprite(roomInfo); } //挂载房间导航区域 @@ -609,6 +611,117 @@ } } + private void CreatePreviewSprite(RoomInfo roomInfo) + { + //房间区域 + var sprite = new Sprite2D(); + sprite.Centered = false; + sprite.Texture = roomInfo.PreviewTexture; + sprite.Position = roomInfo.Position; + var material = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); + material.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); + material.SetShaderParameter("scale", 0.5f); + sprite.Material = material; + roomInfo.PreviewSprite = sprite; + + //过道 + if (roomInfo.Doors != null) + { + foreach (var doorInfo in roomInfo.Doors) + { + if (doorInfo.IsForward) + { + var aisleSprite = new Sprite2D(); + aisleSprite.Centered = false; + aisleSprite.Texture = doorInfo.AislePreviewTexture; + //调整过道预览位置 + + if (!doorInfo.HasCross) //不含交叉点 + { + if (doorInfo.Direction == DoorDirection.N) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, doorInfo.AislePreviewTexture.GetHeight() - 1); + } + else if (doorInfo.Direction == DoorDirection.S) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, 1); + } + else if (doorInfo.Direction == DoorDirection.E) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, 0); + } + else if (doorInfo.Direction == DoorDirection.W) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 1, 0); + } + } + else //包含交叉点 + { + if (doorInfo.Direction == DoorDirection.S) + { + if (doorInfo.ConnectDoor.Direction == DoorDirection.E) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 4, 1); + } + else if (doorInfo.ConnectDoor.Direction == DoorDirection.W) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, 1); + } + else + { + aisleSprite.Position = doorInfo.OriginPosition; + } + } + else if (doorInfo.Direction == DoorDirection.N) + { + if (doorInfo.ConnectDoor.Direction == DoorDirection.W) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, doorInfo.AislePreviewTexture.GetHeight() - 1); + } + else + { + aisleSprite.Position = doorInfo.OriginPosition; + } + } + else if (doorInfo.Direction == DoorDirection.W) + { + if (doorInfo.ConnectDoor.Direction == DoorDirection.N) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 1, 0); + } + else + { + aisleSprite.Position = doorInfo.OriginPosition; + } + } + else if (doorInfo.Direction == DoorDirection.E) + { + if (doorInfo.ConnectDoor.Direction == DoorDirection.S) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, doorInfo.AislePreviewTexture.GetHeight() - 4); + } + else if (doorInfo.ConnectDoor.Direction == DoorDirection.N) + { + aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, 0); + } + else + { + aisleSprite.Position = doorInfo.OriginPosition; + } + } + } + + var aisleSpriteMaterial = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); + aisleSpriteMaterial.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); + aisleSpriteMaterial.SetShaderParameter("scale", 0.5f); + aisleSprite.Material = aisleSpriteMaterial; + doorInfo.AislePreviewSprite = aisleSprite; + doorInfo.ConnectDoor.AislePreviewSprite = aisleSprite; + } + } + } + } + /// /// 玩家第一次进入某个房间回调 /// diff --git a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs index 5329297..1871d81 100644 --- a/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs @@ -8,7 +8,7 @@ public override void OnCreateUi() { - DrawRoom(); + InitMap(); } public override void OnDestroyUi() @@ -32,114 +32,23 @@ S_Root.Instance.Position = S_DrawContainer.Instance.Size / 2 - Player.Current.Position / 16 * S_Root.Instance.Scale; } - private void DrawRoom() + //初始化小地图 + private void InitMap() { var startRoom = GameApplication.Instance.DungeonManager.StartRoomInfo; startRoom.EachRoom(roomInfo => { - //房间区域 - var sprite = new Sprite2D(); - sprite.Centered = false; - sprite.Texture = roomInfo.PreviewTexture; - sprite.Position = roomInfo.Position; - var material = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); - material.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); - material.SetShaderParameter("scale", 0.5f); - sprite.Material = material; - S_Root.AddChild(sprite); - - //过道 + roomInfo.PreviewSprite.Visible = false; + S_Root.AddChild(roomInfo.PreviewSprite); + if (roomInfo.Doors != null) { - foreach (var doorInfo in roomInfo.Doors) + foreach (var roomInfoDoor in roomInfo.Doors) { - if (doorInfo.IsForward) + if (roomInfoDoor.IsForward) { - var aisleSprite = new Sprite2D(); - aisleSprite.Centered = false; - aisleSprite.Texture = doorInfo.AislePreviewTexture; - //调整过道预览位置 - - if (!doorInfo.HasCross) //不含交叉点 - { - if (doorInfo.Direction == DoorDirection.N) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, doorInfo.AislePreviewTexture.GetHeight() - 1); - } - else if (doorInfo.Direction == DoorDirection.S) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, 1); - } - else if (doorInfo.Direction == DoorDirection.E) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, 0); - } - else if (doorInfo.Direction == DoorDirection.W) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 1, 0); - } - } - else //包含交叉点 - { - if (doorInfo.Direction == DoorDirection.S) - { - if (doorInfo.ConnectDoor.Direction == DoorDirection.E) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 4, 1); - } - else if (doorInfo.ConnectDoor.Direction == DoorDirection.W) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, 1); - } - else - { - aisleSprite.Position = doorInfo.OriginPosition; - } - } - else if (doorInfo.Direction == DoorDirection.N) - { - if (doorInfo.ConnectDoor.Direction == DoorDirection.W) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(0, doorInfo.AislePreviewTexture.GetHeight() - 1); - } - else - { - aisleSprite.Position = doorInfo.OriginPosition; - } - } - else if (doorInfo.Direction == DoorDirection.W) - { - if (doorInfo.ConnectDoor.Direction == DoorDirection.N) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(doorInfo.AislePreviewTexture.GetWidth() - 1, 0); - } - else - { - aisleSprite.Position = doorInfo.OriginPosition; - } - } - else if (doorInfo.Direction == DoorDirection.E) - { - if (doorInfo.ConnectDoor.Direction == DoorDirection.S) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, doorInfo.AislePreviewTexture.GetHeight() - 4); - } - else if (doorInfo.ConnectDoor.Direction == DoorDirection.N) - { - aisleSprite.Position = doorInfo.OriginPosition - new Vector2I(1, 0); - } - else - { - aisleSprite.Position = doorInfo.OriginPosition; - } - } - } - - var aisleSpriteMaterial = ResourceManager.Load(ResourcePath.resource_material_Outline2_tres); - aisleSpriteMaterial.SetShaderParameter("outline_color", new Color(1, 1, 1, 0.9f)); - aisleSpriteMaterial.SetShaderParameter("scale", 0.5f); - aisleSprite.Material = aisleSpriteMaterial; - S_Root.AddChild(aisleSprite); + roomInfoDoor.AislePreviewSprite.Visible = false; + S_Root.AddChild(roomInfoDoor.AislePreviewSprite); } } }