From 307e3dd63f649db2f75b19af31c34690661aa854 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=A8=E8=90=BD=E5=9F=BA=E5=9B=B4=E8=99=BE?= <3161880837@qq.com> Date: Thu, 28 Aug 2025 08:15:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=9B=B8=E6=9C=BA=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0CameraManager=E7=B1=BB=E5=B9=B6=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E7=8E=A9=E5=AE=B6=E8=B7=9F=E9=9A=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(物品展示): 修改ItemShow状态机自动隐藏逻辑 feat(游戏逻辑): 添加玩家死亡时的游戏结束界面 style(场景配置): 调整World场景中相机节点位置和偏移 feat(UI): 为ItemShow添加显示动画并更新动画库 --- .../Scenes/FullscreenPanels/GameOver.tscn | 27 ++++++++++++++++ components/Scenes/UI.tscn | 7 +++- components/Scenes/World.tscn | 5 ++- components/UI/ItemShow.tscn | 32 +++++++++++++++++-- scripts/Statemachine/EntityBase.gd | 4 ++- scripts/Statemachine/ItemShow.gd | 2 ++ scripts/Tools/CameraManager.gd | 10 ++++++ 7 files changed, 80 insertions(+), 7 deletions(-) create mode 100644 components/Scenes/FullscreenPanels/GameOver.tscn diff --git a/components/Scenes/FullscreenPanels/GameOver.tscn b/components/Scenes/FullscreenPanels/GameOver.tscn new file mode 100644 index 0000000..4405631 --- /dev/null +++ b/components/Scenes/FullscreenPanels/GameOver.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=3 uid="uid://beo6s1kudbbve"] + +[ext_resource type="PackedScene" uid="uid://d3qojeqa3difn" path="res://components/Abstracts/FullscreenPanelBase.tscn" id="1_u2ynr"] +[ext_resource type="FontFile" uid="uid://db2jl4bq8idec" path="res://resources/fonts/swyc.ttf" id="3_oynlg"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7gbuu"] +bg_color = Color(1, 0, 0, 0.3) + +[sub_resource type="LabelSettings" id="LabelSettings_17i5j"] +font = ExtResource("3_oynlg") +font_size = 50 + +[node name="GameOver" instance=ExtResource("1_u2ynr")] + +[node name="wrapper" parent="content" index="0"] +theme_override_constants/separation = 50 + +[node name="container" type="PanelContainer" parent="content/wrapper" index="0"] +layout_mode = 2 +size_flags_vertical = 3 +theme_override_styles/panel = SubResource("StyleBoxFlat_7gbuu") + +[node name="text" type="Label" parent="content/wrapper/container" index="0"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "败北" +label_settings = SubResource("LabelSettings_17i5j") diff --git a/components/Scenes/UI.tscn b/components/Scenes/UI.tscn index 451cbcf..0847092 100644 --- a/components/Scenes/UI.tscn +++ b/components/Scenes/UI.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://dfwg750a47ggx"] +[gd_scene load_steps=11 format=3 uid="uid://dfwg750a47ggx"] [ext_resource type="PackedScene" uid="uid://ofpg5s3j7esv" path="res://components/UI/BossBar.tscn" id="1_2pe58"] [ext_resource type="Script" path="res://scripts/Statemachine/UIState.gd" id="1_f00a6"] @@ -7,6 +7,7 @@ [ext_resource type="PackedScene" uid="uid://1n28ji5sl6bx" path="res://components/Scenes/FullscreenPanels/MakeFeed.tscn" id="4_kkki3"] [ext_resource type="Theme" uid="uid://b6nox1qqh50ub" path="res://themes/smallText.tres" id="5_widd7"] [ext_resource type="StyleBox" uid="uid://bsv1daadkv4eq" path="res://styleboxes/topLeftPanel.tres" id="6_8m0pt"] +[ext_resource type="PackedScene" uid="uid://beo6s1kudbbve" path="res://components/Scenes/FullscreenPanels/GameOver.tscn" id="6_10ay6"] [ext_resource type="Texture2D" uid="uid://k13cte17httt" path="res://resources/items/energy.svg" id="7_2om12"] [ext_resource type="PackedScene" uid="uid://d1ulrvupa76ap" path="res://components/UI/ColorBar.tscn" id="9_44nw8"] @@ -73,6 +74,10 @@ metadata/_edit_lock_ = true visible = false layout_mode = 1 +[node name="GameOver" parent="root/panels" instance=ExtResource("6_10ay6")] +visible = false +layout_mode = 1 + [node name="energy" type="PanelContainer" parent="root"] custom_minimum_size = Vector2(300, 0) layout_mode = 1 diff --git a/components/Scenes/World.tscn b/components/Scenes/World.tscn index 9422dee..3ee3491 100644 --- a/components/Scenes/World.tscn +++ b/components/Scenes/World.tscn @@ -18,11 +18,10 @@ position = Vector2(468, 320) texture = ExtResource("6_p0nkj") [node name="rooster" parent="." groups=["players"] instance=ExtResource("3_5ui6q")] -position = Vector2(394, 274) -[node name="camera" type="Camera2D" parent="rooster"] +[node name="camera" type="Camera2D" parent="."] process_mode = 3 -position = Vector2(0, -100) +offset = Vector2(0, -80) process_callback = 0 position_smoothing_enabled = true script = ExtResource("5_mk7bv") diff --git a/components/UI/ItemShow.tscn b/components/UI/ItemShow.tscn index ba80d9a..29f22cb 100644 --- a/components/UI/ItemShow.tscn +++ b/components/UI/ItemShow.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=3 uid="uid://bbm8l3hr4ihar"] +[gd_scene load_steps=7 format=3 uid="uid://bbm8l3hr4ihar"] [ext_resource type="Script" path="res://scripts/Statemachine/ItemShow.gd" id="1_2dhsb"] [ext_resource type="Texture2D" uid="uid://bks8jmctleina" path="res://resources/items/baseball.svg" id="1_hyowb"] @@ -54,10 +54,38 @@ tracks/1/keys = { "times": PackedFloat32Array(0, 0.5) } +[sub_resource type="Animation" id="Animation_pv00d"] +resource_name = "hide" +length = 0.5 +step = 0.1 +tracks/0/type = "bezier" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath(".:scale:x") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(1e-05, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5) +} +tracks/1/type = "bezier" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath(".:modulate:a") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"handle_modes": PackedInt32Array(0, 0), +"points": PackedFloat32Array(0, -0.25, 0, 0.25, 0, 1, -0.25, 0, 0.25, 0), +"times": PackedFloat32Array(0, 0.5) +} + [sub_resource type="AnimationLibrary" id="AnimationLibrary_xbbtb"] _data = { "RESET": SubResource("Animation_6sxrr"), -"hide": SubResource("Animation_ltvf2") +"hide": SubResource("Animation_ltvf2"), +"show": SubResource("Animation_pv00d") } [node name="ItemShow" type="HBoxContainer"] diff --git a/scripts/Statemachine/EntityBase.gd b/scripts/Statemachine/EntityBase.gd index e7b8149..7ae7bf3 100644 --- a/scripts/Statemachine/EntityBase.gd +++ b/scripts/Statemachine/EntityBase.gd @@ -188,7 +188,9 @@ func tryDie(by: BulletBase): if MathTool.rate(GameRule.appleDropRate + by.launcher.fields.get(FieldStore.Entity.DROP_APPLE_RATE)) or isBoss: for i in randi_range(appleCount.x, appleCount.y): ItemDropped.generate(ItemStore.ItemType.APPLE, 1, position + MathTool.randv2_range(GameRule.itemDroppedSpawnOffset)) - die() + await die() + if isPlayer() and UIState.player == self: + UIState.setPanel("GameOver") func tryHeal(count: float): if inventory[ItemStore.ItemType.APPLE] > 0 and health < fields.get(FieldStore.Entity.MAX_HEALTH): inventory[ItemStore.ItemType.APPLE] -= 1 diff --git a/scripts/Statemachine/ItemShow.gd b/scripts/Statemachine/ItemShow.gd index ed3e206..fb36137 100644 --- a/scripts/Statemachine/ItemShow.gd +++ b/scripts/Statemachine/ItemShow.gd @@ -12,6 +12,8 @@ class_name ItemShow func _ready(): if autoFree: + animator.play("show") + await animator.animation_finished await TickTool.millseconds(GameRule.itemShowStayTime) # 等待几秒后自动隐藏 animator.play("hide") await animator.animation_finished diff --git a/scripts/Tools/CameraManager.gd b/scripts/Tools/CameraManager.gd index 1977a39..a0057fc 100644 --- a/scripts/Tools/CameraManager.gd +++ b/scripts/Tools/CameraManager.gd @@ -1 +1,11 @@ +@tool extends Camera2D +class_name CameraManager + +static var camera: Camera2D = null + +func _ready(): + camera = self +func _physics_process(_delta): + if is_instance_valid(UIState.player): + position = UIState.player.position