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