Add debugging information to the mini map.

为迷你地图加入调试信息。
This commit is contained in:
Cold-Mint 2024-09-05 11:50:05 +08:00
parent 41a2cebf41
commit 781c50ee30
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
5 changed files with 73 additions and 20 deletions

View File

@ -117,4 +117,5 @@ log_contact_with_tiles_disables_damage,与瓦片接触禁用伤害。,"Disabling
log_hide_all_node,隐藏{0}个节点。,Hide {0} nodes.,{0}ノードを非表示にします。 log_hide_all_node,隐藏{0}个节点。,Hide {0} nodes.,{0}ノードを非表示にします。
log_show_all_node,显示{0}个节点。,Show {0} nodes.,{0}ノードが表示されます。 log_show_all_node,显示{0}个节点。,Show {0} nodes.,{0}ノードが表示されます。
log_enter_the_screen,进入屏幕。,Enter screen,画面に移動。 log_enter_the_screen,进入屏幕。,Enter screen,画面に移動。
log_exit_the_screen,退出屏幕。,Exit screen,画面を終了します。 log_exit_the_screen,退出屏幕。,Exit screen,画面を終了します。
log_failed_to_create_room_preview,创建{0}的房间预览图失败。,Failed to create a room preview of the {0}.,{0}の部屋のプレビューを作成できませんでした。
1 id zh en ja
117 log_hide_all_node 隐藏{0}个节点。 Hide {0} nodes. {0}ノードを非表示にします。
118 log_show_all_node 显示{0}个节点。 Show {0} nodes. {0}ノードが表示されます。
119 log_enter_the_screen 进入屏幕。 Enter screen 画面に移動。
120 log_exit_the_screen 退出屏幕。 Exit screen 画面を終了します。
121 log_failed_to_create_room_preview 创建{0}的房间预览图失败。 Failed to create a room preview of the {0}. {0}の部屋のプレビューを作成できませんでした。

View File

@ -28,10 +28,10 @@ anchor_left = 1.0
anchor_top = 1.0 anchor_top = 1.0
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
offset_left = -174.0 offset_left = -1102.0
offset_top = -177.0 offset_top = -525.0
offset_right = -24.0 offset_right = -952.0
offset_bottom = -27.0 offset_bottom = -375.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
texture = ExtResource("1_h88bi") texture = ExtResource("1_h88bi")

View File

@ -82,6 +82,12 @@ public static class Config
/// </summary> /// </summary>
public const float ThrownItemsHitEnemiesReduceSpeedByPercentage = 0.5f; public const float ThrownItemsHitEnemiesReduceSpeedByPercentage = 0.5f;
/// <summary>
/// <para>Scale of the room preview view</para>
/// <para>房间预览图的缩放</para>
/// </summary>
public const float RoomPreviewScale = 1f;
/// <summary> /// <summary>
/// <para>How much blood does a heart represent</para> /// <para>How much blood does a heart represent</para>
/// <para>一颗心代表多少血量</para> /// <para>一颗心代表多少血量</para>

View File

@ -341,24 +341,15 @@ public static class MapGenerator
return false; return false;
} }
//Create a room preview image. var tileMapLayer = roomPlacementData.NewRoom.GetTileMapLayer(Config.TileMapLayerName.Ground);
//创建房间预览图。 if (!CreateRoomPreview(tileMapLayer,
var image = RoomPreview.CreateImage(roomPlacementData.NewRoom.GetTileMapLayer(Config.TileMapLayerName.Ground)); CalculateRelativePositionOnTheMinimap(tileMapLayer, roomPlacementData)))
if (GameSceneDepend.MiniMapContainerNode == null || roomPlacementData.Position == null ||
image == null)
{ {
LogCat.LogWithFormat("failed_to_create_room_preview", LogCat.LogLabel.Default, LogCat.UploadFormat,
roomNodeDataId);
return false; return false;
} }
var sprite = new Sprite2D();
sprite.Scale = new Vector2(5, 5);
sprite.Texture = image;
//TODOCalculate the coordinates of the room preview view.
//TODO计算房间预览图的坐标。
sprite.Position = GameSceneDepend.MiniMapMidpointCoordinate +
roomPlacementData.Position.Value / Config.CellSize;
NodeUtils.CallDeferredAddChild(GameSceneDepend.MiniMapContainerNode, sprite);
//Rooms are added to the dictionary only after the preview is created. //Rooms are added to the dictionary only after the preview is created.
//创建预览图后才将房间添加到字典。 //创建预览图后才将房间添加到字典。
dictionary.Add(roomNodeDataId, roomPlacementData.NewRoom); dictionary.Add(roomNodeDataId, roomPlacementData.NewRoom);
@ -366,4 +357,59 @@ public static class MapGenerator
roomPlacementData.Position.ToString()); roomPlacementData.Position.ToString());
return true; return true;
} }
/// <summary>
/// <para>CalculateRelativePositionOnTheMinimap</para>
/// <para>计算在迷你地图上的相对位置</para>
/// </summary>
/// <returns>
///<para>Returns the position relative to the point in the minimap container</para>
///<para>返回相对对于迷你地图容器中点的位置</para>
/// </returns>
private static Vector2? CalculateRelativePositionOnTheMinimap(TileMapLayer? groundTileMapLayer,
RoomPlacementData roomPlacementData)
{
if (groundTileMapLayer == null || roomPlacementData.Position == null)
{
return null;
}
return roomPlacementData.Position.Value / Config.CellSize * Config.RoomPreviewScale;
}
/// <summary>
/// <para>Create a room preview image.</para>
/// <para>创建房间预览图</para>
/// </summary>
/// <param name="groundTileMapLayer">
///<para>Layers that need to be drawn onto a minimap</para>
///<para>需要绘制到迷你地图上的图层</para>
/// </param>
/// <param name="position">
///<para>Relative to the position of the point in the minimap container</para>
///<para>相对于迷你地图容器中点的位置</para>
/// </param>
/// <returns></returns>
private static bool CreateRoomPreview(TileMapLayer? groundTileMapLayer, Vector2? position)
{
if (GameSceneDepend.MiniMapContainerNode == null || position == null)
{
return false;
}
var image = RoomPreview.CreateImage(groundTileMapLayer);
if (image == null)
{
return false;
}
var sprite = new Sprite2D();
sprite.Scale = new Vector2(Config.RoomPreviewScale, Config.RoomPreviewScale);
sprite.Texture = image;
sprite.Position = GameSceneDepend.MiniMapMidpointCoordinate + position.Value;
NodeUtils.CallDeferredAddChild(GameSceneDepend.MiniMapContainerNode, sprite);
return true;
}
} }

View File

@ -55,7 +55,7 @@ public static class RoomPreview
//Create an image. //Create an image.
//创建image。 //创建image。
var image = Image.CreateEmpty(width + 1, height + 1, false, Image.Format.Rgba8); var image = Image.CreateEmpty(width + 1, height + 1, false, Image.Format.Rgba8);
//image.Fill(Colors.Green); image.Fill(Colors.Green);
//Fill in pixels //Fill in pixels
//填充像素点 //填充像素点
foreach (var vector2I in cellsArray) foreach (var vector2I in cellsArray)