diff --git a/scenes/mapContainer.tscn b/scenes/mapContainer.tscn index 46daf76..8f3473f 100644 --- a/scenes/mapContainer.tscn +++ b/scenes/mapContainer.tscn @@ -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="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"] +[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"] layout_mode = 3 anchors_preset = 15 @@ -13,6 +103,11 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 +[node name="MiniMapAnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_d5o4b") +} + [node name="ColorRect" type="ColorRect" parent="."] visible = false layout_mode = 1 @@ -23,19 +118,26 @@ grow_horizontal = 2 grow_vertical = 2 mouse_filter = 2 -[node name="MiniMap" type="NinePatchRect" parent="."] +[node name="Control" type="Control" parent="."] layout_mode = 1 anchors_preset = 3 anchor_left = 1.0 anchor_top = 1.0 anchor_right = 1.0 anchor_bottom = 1.0 -offset_left = -169.0 -offset_top = -168.0 -offset_right = -19.0 -offset_bottom = -18.0 +offset_left = -163.0 +offset_top = -163.0 +offset_right = -123.0 +offset_bottom = -123.0 grow_horizontal = 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") patch_margin_left = 7 patch_margin_top = 7 @@ -43,8 +145,8 @@ patch_margin_right = 7 patch_margin_bottom = 7 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) texture = ExtResource("3_x80y0") diff --git a/scripts/GameSceneDepend.cs b/scripts/GameSceneDepend.cs index 7d43824..722fb28 100644 --- a/scripts/GameSceneDepend.cs +++ b/scripts/GameSceneDepend.cs @@ -17,6 +17,12 @@ public static class GameSceneDepend /// 迷你地图 /// public static MiniMap? MiniMap { get; set; } + + /// + /// MiniMapAnimationPlayer + /// 迷你地图的动画节点 + /// + public static AnimationPlayer? MiniMapAnimationPlayer { get; set; } private static Player? _player; diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs index d15d807..40a7fee 100644 --- a/scripts/loader/sceneLoader/GameSceneLoader.cs +++ b/scripts/loader/sceneLoader/GameSceneLoader.cs @@ -63,8 +63,12 @@ public partial class GameSceneLoader : SceneLoaderTemplate GameSceneDepend.PickAbleContainer = pickAbleContainer; //Setting up the mini map //设置迷你地图 - var miniMap = GetNode("CanvasLayer/Control/MapContainer/MiniMap"); + var miniMap = GetNode("CanvasLayer/Control/MapContainer/Control/MiniMap"); GameSceneDepend.MiniMap = miniMap; + //Set the mini map animation + //设置迷你地图动画 + var miniMapAnimationPlayer = GetNode("CanvasLayer/Control/MapContainer/MiniMapAnimationPlayer"); + GameSceneDepend.MiniMapAnimationPlayer = miniMapAnimationPlayer; return Task.CompletedTask; } diff --git a/scripts/map/room/Room.cs b/scripts/map/room/Room.cs index ca88251..2f85da1 100644 --- a/scripts/map/room/Room.cs +++ b/scripts/map/room/Room.cs @@ -191,7 +191,10 @@ public class Room //Complete all waves. //完成所有的波次。 ClearAllMatchedBarriers(); - GameSceneDepend.MiniMap?.Show(); + if (GameSceneDepend.MiniMap != null && !GameSceneDepend.MiniMap.Visible) + { + GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "show"); + } return; } NodeUtils.ForEachNode(_autoSpawn, marker => @@ -219,7 +222,10 @@ public class Room }); if (_spawnedCharacterTemplateList.Count > 0) { - GameSceneDepend.MiniMap?.Hide(); + if (GameSceneDepend.MiniMap != null && GameSceneDepend.MiniMap.Visible) + { + GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "hide"); + } AddTimer(PlaceBarriersInAllSlots); } }