diff --git a/scenes/mapContainer.tscn b/scenes/mapContainer.tscn
index 155524c..46daf76 100644
--- a/scenes/mapContainer.tscn
+++ b/scenes/mapContainer.tscn
@@ -1,6 +1,8 @@
-[gd_scene load_steps=2 format=3 uid="uid://c74180dtf7j7a"]
+[gd_scene load_steps=4 format=3 uid="uid://c74180dtf7j7a"]
[ext_resource type="Texture2D" uid="uid://c35bsle7thcnh" path="res://sprites/ui/MiniMapBg.png" id="1_h88bi"]
+[ext_resource type="Script" path="res://scripts/map/miniMap/MiniMap.cs" id="2_ltp8b"]
+[ext_resource type="Texture2D" uid="uid://cfpcm0hkmpu38" path="res://sprites/ui/mark.png" id="3_x80y0"]
[node name="MapContainer" type="Control"]
layout_mode = 3
@@ -28,10 +30,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
-offset_left = -1102.0
-offset_top = -525.0
-offset_right = -952.0
-offset_bottom = -375.0
+offset_left = -169.0
+offset_top = -168.0
+offset_right = -19.0
+offset_bottom = -18.0
grow_horizontal = 0
grow_vertical = 0
texture = ExtResource("1_h88bi")
@@ -39,5 +41,10 @@ patch_margin_left = 7
patch_margin_top = 7
patch_margin_right = 7
patch_margin_bottom = 7
+script = ExtResource("2_ltp8b")
[node name="RoomPreviewContainer" type="Node2D" parent="MiniMap"]
+
+[node name="Mark" type="Sprite2D" parent="MiniMap"]
+position = Vector2(75, 75)
+texture = ExtResource("3_x80y0")
diff --git a/scripts/Config.cs b/scripts/Config.cs
index e9a2f9e..7672413 100644
--- a/scripts/Config.cs
+++ b/scripts/Config.cs
@@ -86,7 +86,7 @@ public static class Config
/// Scale of the room preview view
/// 房间预览图的缩放
///
- public const float RoomPreviewScale = 1f;
+ public const float RoomPreviewScale = 5f;
///
/// How much blood does a heart represent
diff --git a/scripts/EventManager.cs b/scripts/EventManager.cs
index ab2d847..6f68d25 100644
--- a/scripts/EventManager.cs
+++ b/scripts/EventManager.cs
@@ -38,10 +38,4 @@ public static class EventManager
/// 地图生成完成事件
///
public static Action? MapGenerationCompleteEvent;
-
- ///
- /// Player Instance Change Event
- /// 玩家实例改变事件
- ///
- public static Action? PlayerInstanceChangeEvent;
}
\ No newline at end of file
diff --git a/scripts/GameSceneDepend.cs b/scripts/GameSceneDepend.cs
index 134fced..e5d25e8 100644
--- a/scripts/GameSceneDepend.cs
+++ b/scripts/GameSceneDepend.cs
@@ -1,7 +1,7 @@
using ColdMint.scripts.character;
using ColdMint.scripts.inventory;
using ColdMint.scripts.loader.uiLoader;
-using ColdMint.scripts.map.events;
+using ColdMint.scripts.map.miniMap;
using ColdMint.scripts.utils;
using Godot;
@@ -14,11 +14,11 @@ namespace ColdMint.scripts;
public static class GameSceneDepend
{
///
- /// The midpoint of the minimap
- /// 迷你地图的中点
+ /// MiniMap
+ /// 迷你地图
///
- public static Vector2 MiniMapMidpointCoordinate;
-
+ public static MiniMap? MiniMap { get; set; }
+
private static Player? _player;
///
@@ -31,13 +31,10 @@ public static class GameSceneDepend
set
{
_player = value;
- //Broadcast the event to the outside when the player instance changes.
- //当玩家实例改变时,向外广播事件。
- var playerInstanceChangeEvent = new PlayerInstanceChangeEvent
+ if (MiniMap != null)
{
- PlayerInstance = _player
- };
- EventManager.PlayerInstanceChangeEvent?.Invoke(playerInstanceChangeEvent);
+ MiniMap.OwnerNode = _player;
+ }
}
}
@@ -46,7 +43,7 @@ public static class GameSceneDepend
/// 鼠标进入到某个角色的范围内时,会将其视作目标
///
public static Node2D? TemporaryTargetNode { get; set; }
-
+
///
/// MiniMapContainerNode
/// 迷你地图容器节点
diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs
index 69c827d..0c3303b 100644
--- a/scripts/loader/sceneLoader/GameSceneLoader.cs
+++ b/scripts/loader/sceneLoader/GameSceneLoader.cs
@@ -3,6 +3,7 @@ using ColdMint.scripts.inventory;
using ColdMint.scripts.map;
using ColdMint.scripts.map.LayoutParsingStrategy;
using ColdMint.scripts.map.layoutStrategy;
+using ColdMint.scripts.map.miniMap;
using ColdMint.scripts.map.RoomPlacer;
using ColdMint.scripts.utils;
using Godot;
@@ -60,9 +61,10 @@ public partial class GameSceneLoader : SceneLoaderTemplate
//加载房间容器节点
var miniMapContainerNode = GetNode("CanvasLayer/Control/MapContainer/MiniMap/RoomPreviewContainer");
GameSceneDepend.MiniMapContainerNode = miniMapContainerNode;
- //计算迷你地图的中点
- var mapContainer = GetNode("CanvasLayer/Control/MapContainer/MiniMap");
- GameSceneDepend.MiniMapMidpointCoordinate = mapContainer.Size / 2;
+ //Setting up the mini map
+ //设置迷你地图
+ var miniMap = GetNode("CanvasLayer/Control/MapContainer/MiniMap");
+ GameSceneDepend.MiniMap = miniMap;
return Task.CompletedTask;
}
diff --git a/scripts/map/MapGenerator.cs b/scripts/map/MapGenerator.cs
index 347f4fb..72944b9 100644
--- a/scripts/map/MapGenerator.cs
+++ b/scripts/map/MapGenerator.cs
@@ -373,8 +373,6 @@ public static class MapGenerator
{
return null;
}
-
-
return roomPlacementData.Position.Value / Config.CellSize * Config.RoomPreviewScale;
}
@@ -408,7 +406,11 @@ public static class MapGenerator
var sprite = new TextureRect();
sprite.Scale = new Vector2(Config.RoomPreviewScale, Config.RoomPreviewScale);
sprite.Texture = image;
- sprite.Position = GameSceneDepend.MiniMapMidpointCoordinate + position.Value;
+ if (GameSceneDepend.MiniMap != null)
+ {
+ sprite.Position = GameSceneDepend.MiniMap.MiniMapMidpointCoordinate + position.Value;
+ }
+
NodeUtils.CallDeferredAddChild(GameSceneDepend.MiniMapContainerNode, sprite);
return true;
}
diff --git a/scripts/map/events/PlayerInstanceChangeEvent.cs b/scripts/map/events/PlayerInstanceChangeEvent.cs
deleted file mode 100644
index f08abfb..0000000
--- a/scripts/map/events/PlayerInstanceChangeEvent.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using ColdMint.scripts.character;
-
-namespace ColdMint.scripts.map.events;
-
-///
-/// Player instance change event
-/// 玩家实例改变事件
-///
-public class PlayerInstanceChangeEvent
-{
- ///
- /// New player instance
- /// 新的玩家实例
- ///
- // ReSharper disable UnusedAutoPropertyAccessor.Global
- public Player? PlayerInstance { get; set; }
- // ReSharper restore UnusedAutoPropertyAccessor.Global
-}
\ No newline at end of file
diff --git a/scripts/map/miniMap/MiniMap.cs b/scripts/map/miniMap/MiniMap.cs
new file mode 100644
index 0000000..9190ec3
--- /dev/null
+++ b/scripts/map/miniMap/MiniMap.cs
@@ -0,0 +1,44 @@
+using Godot;
+
+namespace ColdMint.scripts.map.miniMap;
+
+///
+/// Mini Map
+/// 迷你地图
+///
+public partial class MiniMap : NinePatchRect
+{
+ private Node2D? _roomPreviewContainer;
+ private Vector2 _miniMapMidpointCoordinate;
+
+ ///
+ /// The midpoint coordinates of the mini map
+ /// 迷你地图的中点坐标
+ ///
+ public Vector2 MiniMapMidpointCoordinate => _miniMapMidpointCoordinate;
+
+ ///
+ /// The master node of the map
+ /// 地图的主人节点
+ ///
+ public Node2D? OwnerNode { get; set; }
+
+ public override void _Ready()
+ {
+ _roomPreviewContainer = GetNode("RoomPreviewContainer");
+ _miniMapMidpointCoordinate = Size / 2;
+ }
+
+ public override void _Process(double delta)
+ {
+ if (_roomPreviewContainer == null)
+ {
+ return;
+ }
+
+ if (OwnerNode != null)
+ {
+ _roomPreviewContainer.Position = -OwnerNode.GlobalPosition / Config.CellSize * Config.RoomPreviewScale;
+ }
+ }
+}
\ No newline at end of file
diff --git a/sprites/ui/mark.png b/sprites/ui/mark.png
new file mode 100644
index 0000000..b89b040
Binary files /dev/null and b/sprites/ui/mark.png differ
diff --git a/sprites/ui/mark.png.import b/sprites/ui/mark.png.import
new file mode 100644
index 0000000..5a8d9e7
--- /dev/null
+++ b/sprites/ui/mark.png.import
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://cfpcm0hkmpu38"
+path="res://.godot/imported/mark.png-81a29d16cd3553688c08d78ed11d42ca.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://sprites/ui/mark.png"
+dest_files=["res://.godot/imported/mark.png-81a29d16cd3553688c08d78ed11d42ca.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