Add animations to show and hide mini maps.

为迷你地图的显示和隐藏加入动画。
This commit is contained in:
Cold-Mint 2024-10-09 10:21:26 +08:00
parent 53889ef2fd
commit d1c0f1e265
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
4 changed files with 129 additions and 11 deletions

View File

@ -1,9 +1,99 @@
[gd_scene load_steps=4 format=3 uid="uid://c74180dtf7j7a"] [gd_scene load_steps=8 format=3 uid="uid://c74180dtf7j7a"]
[ext_resource type="Texture2D" uid="uid://c35bsle7thcnh" path="res://sprites/ui/MiniMapBg.png" id="1_h88bi"] [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="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"] [ext_resource type="Texture2D" uid="uid://cfpcm0hkmpu38" path="res://sprites/ui/mark.png" id="3_x80y0"]
[sub_resource type="Animation" id="Animation_jdj6o"]
resource_name = "hide"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Control/MiniMap:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(0, 300)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Control/MiniMap:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 1,
"values": [true, false]
}
[sub_resource type="Animation" id="Animation_dkx17"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Control/MiniMap:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(983, 480)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Control/MiniMap:visible")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
[sub_resource type="Animation" id="Animation_icaqa"]
resource_name = "show"
length = 0.3
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Control/MiniMap:visible")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [true]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Control/MiniMap:position")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.3),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 300), Vector2(0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_d5o4b"]
_data = {
"RESET": SubResource("Animation_dkx17"),
"hide": SubResource("Animation_jdj6o"),
"show": SubResource("Animation_icaqa")
}
[node name="MapContainer" type="Control"] [node name="MapContainer" type="Control"]
layout_mode = 3 layout_mode = 3
anchors_preset = 15 anchors_preset = 15
@ -13,6 +103,11 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
mouse_filter = 2 mouse_filter = 2
[node name="MiniMapAnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_d5o4b")
}
[node name="ColorRect" type="ColorRect" parent="."] [node name="ColorRect" type="ColorRect" parent="."]
visible = false visible = false
layout_mode = 1 layout_mode = 1
@ -23,19 +118,26 @@ grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
mouse_filter = 2 mouse_filter = 2
[node name="MiniMap" type="NinePatchRect" parent="."] [node name="Control" type="Control" parent="."]
layout_mode = 1 layout_mode = 1
anchors_preset = 3 anchors_preset = 3
anchor_left = 1.0 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 = -169.0 offset_left = -163.0
offset_top = -168.0 offset_top = -163.0
offset_right = -19.0 offset_right = -123.0
offset_bottom = -18.0 offset_bottom = -123.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
[node name="MiniMap" type="NinePatchRect" parent="Control"]
layout_mode = 1
offset_left = 983.0
offset_top = 480.0
offset_right = 1133.0
offset_bottom = 630.0
texture = ExtResource("1_h88bi") texture = ExtResource("1_h88bi")
patch_margin_left = 7 patch_margin_left = 7
patch_margin_top = 7 patch_margin_top = 7
@ -43,8 +145,8 @@ patch_margin_right = 7
patch_margin_bottom = 7 patch_margin_bottom = 7
script = ExtResource("2_ltp8b") script = ExtResource("2_ltp8b")
[node name="RoomPreviewContainer" type="Node2D" parent="MiniMap"] [node name="RoomPreviewContainer" type="Node2D" parent="Control/MiniMap"]
[node name="Mark" type="Sprite2D" parent="MiniMap"] [node name="Mark" type="Sprite2D" parent="Control/MiniMap"]
position = Vector2(75, 75) position = Vector2(75, 75)
texture = ExtResource("3_x80y0") texture = ExtResource("3_x80y0")

View File

@ -18,6 +18,12 @@ public static class GameSceneDepend
/// </summary> /// </summary>
public static MiniMap? MiniMap { get; set; } public static MiniMap? MiniMap { get; set; }
/// <summary>
/// <para>MiniMapAnimationPlayer</para>
/// <para>迷你地图的动画节点</para>
/// </summary>
public static AnimationPlayer? MiniMapAnimationPlayer { get; set; }
private static Player? _player; private static Player? _player;
/// <summary> /// <summary>

View File

@ -63,8 +63,12 @@ public partial class GameSceneLoader : SceneLoaderTemplate
GameSceneDepend.PickAbleContainer = pickAbleContainer; GameSceneDepend.PickAbleContainer = pickAbleContainer;
//Setting up the mini map //Setting up the mini map
//设置迷你地图 //设置迷你地图
var miniMap = GetNode<MiniMap>("CanvasLayer/Control/MapContainer/MiniMap"); var miniMap = GetNode<MiniMap>("CanvasLayer/Control/MapContainer/Control/MiniMap");
GameSceneDepend.MiniMap = miniMap; GameSceneDepend.MiniMap = miniMap;
//Set the mini map animation
//设置迷你地图动画
var miniMapAnimationPlayer = GetNode<AnimationPlayer>("CanvasLayer/Control/MapContainer/MiniMapAnimationPlayer");
GameSceneDepend.MiniMapAnimationPlayer = miniMapAnimationPlayer;
return Task.CompletedTask; return Task.CompletedTask;
} }

View File

@ -191,7 +191,10 @@ public class Room
//Complete all waves. //Complete all waves.
//完成所有的波次。 //完成所有的波次。
ClearAllMatchedBarriers(); ClearAllMatchedBarriers();
GameSceneDepend.MiniMap?.Show(); if (GameSceneDepend.MiniMap != null && !GameSceneDepend.MiniMap.Visible)
{
GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "show");
}
return; return;
} }
NodeUtils.ForEachNode<ISpawnMarker>(_autoSpawn, marker => NodeUtils.ForEachNode<ISpawnMarker>(_autoSpawn, marker =>
@ -219,7 +222,10 @@ public class Room
}); });
if (_spawnedCharacterTemplateList.Count > 0) if (_spawnedCharacterTemplateList.Count > 0)
{ {
GameSceneDepend.MiniMap?.Hide(); if (GameSceneDepend.MiniMap != null && GameSceneDepend.MiniMap.Visible)
{
GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "hide");
}
AddTimer(PlaceBarriersInAllSlots); AddTimer(PlaceBarriersInAllSlots);
} }
} }