From 9e1e7f82f5464527174c962cf1d76f3f4834ff02 Mon Sep 17 00:00:00 2001 From: cakipaul Date: Tue, 21 Jan 2025 18:52:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manager/cg_manager/cg_manager.gd | 5 -- .../deploy/{deployer => }/deployer_window.gd | 0 .../{deployer => }/deployer_window.tscn | 2 +- .../deploy/{deployer => }/section_deployer.gd | 0 .../{deployer => }/section_deployer.tscn | 4 +- manager/input/input_manager.gd | 12 --- manager/{deploy => }/scene/scene_manager.gd | 0 project.godot | 4 +- scene/dialog/dialog.gd | 87 ------------------- scene/dialog/dialog.tscn | 33 ------- scene/entity/ambient/light.tscn | 1 - scene/entity/ambush.gd | 10 +-- scene/entity/local_inspectable.gd | 3 +- scene/entity/local_inspectable.tscn | 11 +-- scene/entity/note.gd | 4 +- scene/entity/npc.gd | 2 + scene/entity/old/inspectable.gd | 1 - scene/entity/old/inspectable.tscn | 11 +-- scene/entity/pickable.gd | 2 + scene/entity/ux/animated_sound_sprite_2d.gd | 7 -- scene/entity/ux/cg_event.gd | 2 - scene/entity/ux/cg_event.tscn | 6 -- scene/entity/ux/journal_event.gd | 2 - scene/entity/ux/journal_event.tscn | 6 -- scene/entity/ux/sfx.gd | 8 +- scene/entity/ux/sign.gd | 2 +- scene/ground/ground.gd | 12 +-- scene/ground/ground.tscn | 7 +- scene/ground/ground_loader.gd | 25 +++--- scene/ground/scene/c01/s05_animation.gd | 22 ++++- scene/ground/scene/c01/s05_院长房间.tscn | 11 ++- scene/ground/scene/c02/s03_院子切换.tscn | 3 +- scene/player/main_player.gd | 4 +- ...nventory.gd => prop_inventory_resource.gd} | 0 .../{prop_item.gd => prop_item_resource.gd} | 0 ui/button/item_list_modified.tscn | 6 -- ui/button/sound_texture_button.gd | 37 -------- ui/button/sound_texture_button.tscn | 8 -- util/lru.gd | 1 - 39 files changed, 81 insertions(+), 280 deletions(-) delete mode 100644 manager/cg_manager/cg_manager.gd rename manager/deploy/{deployer => }/deployer_window.gd (100%) rename manager/deploy/{deployer => }/deployer_window.tscn (74%) rename manager/deploy/{deployer => }/section_deployer.gd (100%) rename manager/deploy/{deployer => }/section_deployer.tscn (74%) delete mode 100644 manager/input/input_manager.gd rename manager/{deploy => }/scene/scene_manager.gd (100%) delete mode 100644 scene/dialog/dialog.gd delete mode 100644 scene/dialog/dialog.tscn delete mode 100644 scene/entity/ux/animated_sound_sprite_2d.gd delete mode 100644 scene/entity/ux/cg_event.gd delete mode 100644 scene/entity/ux/cg_event.tscn delete mode 100644 scene/entity/ux/journal_event.gd delete mode 100644 scene/entity/ux/journal_event.tscn rename scene/prop/{prop_inventory.gd => prop_inventory_resource.gd} (100%) rename scene/prop/{prop_item.gd => prop_item_resource.gd} (100%) delete mode 100644 ui/button/item_list_modified.tscn delete mode 100644 ui/button/sound_texture_button.gd delete mode 100644 ui/button/sound_texture_button.tscn diff --git a/manager/cg_manager/cg_manager.gd b/manager/cg_manager/cg_manager.gd deleted file mode 100644 index a9a5c225..00000000 --- a/manager/cg_manager/cg_manager.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Node - - -func play_cg(cg_name: String) -> void: - print("play_cg: ", cg_name) \ No newline at end of file diff --git a/manager/deploy/deployer/deployer_window.gd b/manager/deploy/deployer_window.gd similarity index 100% rename from manager/deploy/deployer/deployer_window.gd rename to manager/deploy/deployer_window.gd diff --git a/manager/deploy/deployer/deployer_window.tscn b/manager/deploy/deployer_window.tscn similarity index 74% rename from manager/deploy/deployer/deployer_window.tscn rename to manager/deploy/deployer_window.tscn index 3c641c84..86a09d5b 100644 --- a/manager/deploy/deployer/deployer_window.tscn +++ b/manager/deploy/deployer_window.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dfbmctdmc4ue6"] -[ext_resource type="Script" path="res://manager/deploy/deployer/deployer_window.gd" id="1_rhcam"] +[ext_resource type="Script" path="res://manager/deploy/deployer_window.gd" id="1_rhcam"] [node name="DeployerWindow" type="Window"] auto_translate_mode = 1 diff --git a/manager/deploy/deployer/section_deployer.gd b/manager/deploy/section_deployer.gd similarity index 100% rename from manager/deploy/deployer/section_deployer.gd rename to manager/deploy/section_deployer.gd diff --git a/manager/deploy/deployer/section_deployer.tscn b/manager/deploy/section_deployer.tscn similarity index 74% rename from manager/deploy/deployer/section_deployer.tscn rename to manager/deploy/section_deployer.tscn index d3833538..1adb20d0 100644 --- a/manager/deploy/deployer/section_deployer.tscn +++ b/manager/deploy/section_deployer.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=4 format=3 uid="uid://jveao8k40jp1"] -[ext_resource type="Script" path="res://manager/deploy/deployer/section_deployer.gd" id="1_komad"] +[ext_resource type="Script" path="res://manager/deploy/section_deployer.gd" id="1_komad"] [ext_resource type="PackedScene" uid="uid://dygvcmykn02n8" path="res://scene/main.tscn" id="2_si45r"] -[ext_resource type="PackedScene" uid="uid://dfbmctdmc4ue6" path="res://manager/deploy/deployer/deployer_window.tscn" id="3_iq8me"] +[ext_resource type="PackedScene" uid="uid://dfbmctdmc4ue6" path="res://manager/deploy/deployer_window.tscn" id="3_iq8me"] [node name="SectionDeployer" type="Node2D"] script = ExtResource("1_komad") diff --git a/manager/input/input_manager.gd b/manager/input/input_manager.gd deleted file mode 100644 index f5f68084..00000000 --- a/manager/input/input_manager.gd +++ /dev/null @@ -1,12 +0,0 @@ -extends Node - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - diff --git a/manager/deploy/scene/scene_manager.gd b/manager/scene/scene_manager.gd similarity index 100% rename from manager/deploy/scene/scene_manager.gd rename to manager/scene/scene_manager.gd diff --git a/project.godot b/project.godot index 9f3cc4d7..51232473 100644 --- a/project.godot +++ b/project.godot @@ -39,11 +39,9 @@ buses/default_bus_layout="res://config/default_bus_layout.tres" DebugMenu="*res://addons/debug_menu/debug_menu.tscn" GlobalConfigManager="*res://manager/config_manager/global_config_manager.gd" ArchiveManager="*res://manager/archive_manager/archive_manager.gd" -SceneManager="*res://manager/deploy/scene/scene_manager.gd" +SceneManager="*res://manager/scene/scene_manager.gd" AudioManager="*res://manager/audio_manager/audio_manager.gd" EventManager="*res://manager/event_manager/event_manager.gd" -CgManager="*res://manager/cg_manager/cg_manager.gd" -InputManager="res://manager/input/input_manager.gd" DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd" [debug] diff --git a/scene/dialog/dialog.gd b/scene/dialog/dialog.gd deleted file mode 100644 index f9008281..00000000 --- a/scene/dialog/dialog.gd +++ /dev/null @@ -1,87 +0,0 @@ -extends Control - -@onready var label = %RichTextLabel as RichTextLabel - -var pending_bbcode = [] -var tweening := false - - -func _ready(): - label.clear() - modulate = Color(1, 1, 1, 0) - # test notification in editor - # if GlobalConfig.DEBUG: - # call_deferred("test") - - -# func test(): -# # append_dialog("吕萍", "Hello, 2! very very long message, very very loooonnnggggggg!") -# append_note("Hello, 3!") -# # append_note("Hello, blue!", "blue", 1) -# append_dialog("车夫", "你好!", "green") -# pass - - -func append_note(note: String, note_color := "white", duration := 2.5) -> void: - pending_bbcode.append( - ["[center][color=" + note_color + "]" + note + "[/color][/center]", duration, false] - ) - _show() - - -func append_dialog( - character: String, - content: String, - character_color := "orange", - content_color := "white", - duration := 2.5 -) -> void: - # remove non-dialog notifications - for _i in range(pending_bbcode.size()): - var triple = pending_bbcode.pop_front() - if not triple[2]: - continue - pending_bbcode.append(triple) - pending_bbcode.append( - [ - ( - "[center][color=" - + character_color - + "][b]" - + character - + ":[/b][/color][color=" - + content_color - + "]" - + content - + "[/color][/center]" - ), - duration, - true - ] - ) - _show() - - -func _show() -> void: - if not tweening and pending_bbcode.size() > 0: - var triple = pending_bbcode.pop_front() - label.parse_bbcode(triple[0]) - if triple[2]: - label.add_theme_color_override("font_shadow_color", Color(0.2, 0.2, 0.2, 0.6)) - else: - label.remove_theme_color_override("font_shadow_color") - tweening = true - var tween = create_tween() - # 0.5s to show the notification - tween.tween_property(self, "modulate:a", 1, 0.2).set_trans(Tween.TRANS_CUBIC) - # keep the notification - tween.tween_interval(max(triple[1] - 0.4, 0)) - # 0.5s to hide the notification - tween.tween_property(self, "modulate:a", 0, 0.2).set_trans(Tween.TRANS_CUBIC) - # callback - tween.tween_callback(_check_next) - - -func _check_next(): - tweening = false - _show() diff --git a/scene/dialog/dialog.tscn b/scene/dialog/dialog.tscn deleted file mode 100644 index dd0f63c1..00000000 --- a/scene/dialog/dialog.tscn +++ /dev/null @@ -1,33 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dmkt1roqc4he7"] - -[ext_resource type="Script" path="res://scene/dialog/dialog.gd" id="1_s1ka3"] - -[node name="Dialog" type="MarginContainer"] -anchors_preset = 7 -anchor_left = 0.5 -anchor_top = 1.0 -anchor_right = 0.5 -anchor_bottom = 1.0 -offset_left = -250.0 -offset_top = -58.0 -offset_right = 250.0 -grow_horizontal = 2 -grow_vertical = 0 -size_flags_vertical = 8 -mouse_filter = 2 -theme_override_constants/margin_bottom = 42 -script = ExtResource("1_s1ka3") - -[node name="RichTextLabel" type="RichTextLabel" parent="."] -unique_name_in_owner = true -custom_minimum_size = Vector2(460, 0) -layout_mode = 2 -size_flags_horizontal = 4 -size_flags_vertical = 4 -mouse_filter = 2 -theme_override_colors/font_shadow_color = Color(0.174626, 0.174626, 0.174626, 1) -theme_override_constants/shadow_offset_y = 1 -theme_override_constants/shadow_offset_x = 1 -bbcode_enabled = true -text = " [center][b][color=orange]吕萍:[/color][/b]「你好呀」[/center]" -fit_content = true diff --git a/scene/entity/ambient/light.tscn b/scene/entity/ambient/light.tscn index 79f993e5..69b55686 100644 --- a/scene/entity/ambient/light.tscn +++ b/scene/entity/ambient/light.tscn @@ -16,7 +16,6 @@ height = 20.0 [node name="NaturalPointLight2D" type="PointLight2D" parent="."] unique_name_in_owner = true -scale = Vector2(1e-05, 1e-05) shadow_color = Color(0, 0, 0, 1) texture = ExtResource("3_w1x1y") height = 40.0 diff --git a/scene/entity/ambush.gd b/scene/entity/ambush.gd index 61d0f50f..63875f7c 100644 --- a/scene/entity/ambush.gd +++ b/scene/entity/ambush.gd @@ -28,7 +28,7 @@ var hook_animation = "" dialogue_res = dialogue_c01 "c02": dialogue_res = dialogue_c02 - if is_node_ready(): + if is_node_ready() and Engine.is_editor_hint(): notify_property_list_changed() var hook_dialogue_title = "" @@ -54,11 +54,11 @@ var played: bool: # Called when the node enters the scene tree for the first time. func _ready() -> void: - var animation_player = _get_animation_player() - # 更新 hook_animation 的可选项 - if animation_player: - animation_player.animation_libraries_updated.connect(notify_property_list_changed) if Engine.is_editor_hint(): + var animation_player = _get_animation_player() + # 更新 hook_animation 的可选项 + if animation_player: + animation_player.animation_libraries_updated.connect(notify_property_list_changed) return _check_sign_display() if one_shot and played: diff --git a/scene/entity/local_inspectable.gd b/scene/entity/local_inspectable.gd index 0866de80..9b34bb51 100644 --- a/scene/entity/local_inspectable.gd +++ b/scene/entity/local_inspectable.gd @@ -15,11 +15,10 @@ enum { STATUS_NORAML, STATUS_INSPECTING_COVER, STATUS_INSPECTING_NOTES } @export_enum("none", "c01", "c02", "c03", "c04", "c05", "c06") var editor_filter := "none": set(val): editor_filter = val - if is_node_ready(): + if is_node_ready() and Engine.is_editor_hint(): notify_property_list_changed() var content_key: String = "" -@onready var sprite2d = %AnimatedSoundSprite2D as AnimatedSoundSprite2D @onready var sign_mark = %Sign as Sign @onready var area2d = %Area2D as Area2D diff --git a/scene/entity/local_inspectable.tscn b/scene/entity/local_inspectable.tscn index 7e8e8f23..aaa9d05a 100644 --- a/scene/entity/local_inspectable.tscn +++ b/scene/entity/local_inspectable.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=10 format=3 uid="uid://ci5anaxsa1apl"] +[gd_scene load_steps=8 format=3 uid="uid://ci5anaxsa1apl"] [ext_resource type="Script" path="res://scene/entity/local_inspectable.gd" id="1_85el0"] [ext_resource type="PackedScene" uid="uid://c85t6stvytvjn" path="res://scene/entity/ux/sfx.tscn" id="2_h0c2s"] [ext_resource type="AudioStream" uid="uid://byjcmxy5crce5" path="res://asset/audio/sfx/ui/纸条.mp3" id="3_3ldx7"] [ext_resource type="Texture2D" uid="uid://bei1s1uucktso" path="res://asset/art/tool/neutral_point_light.webp" id="3_o562w"] [ext_resource type="PackedScene" uid="uid://c4tipnj1cr1j3" path="res://scene/entity/ux/sign.tscn" id="4_do8tr"] -[ext_resource type="SpriteFrames" uid="uid://b7fhheih1hbvf" path="res://config/animation/entity_sprite_frames.tres" id="6_e77p4"] -[ext_resource type="Script" path="res://scene/entity/ux/animated_sound_sprite_2d.gd" id="7_bhwlx"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_4fuic"] resource_local_to_scene = true @@ -38,13 +36,6 @@ energy = 0.0 texture = ExtResource("3_o562w") texture_scale = 0.5 -[node name="AnimatedSoundSprite2D" type="AnimatedSprite2D" parent="."] -unique_name_in_owner = true -visible = false -sprite_frames = ExtResource("6_e77p4") -animation = &"c00_吕萍_记笔记_right" -script = ExtResource("7_bhwlx") - [node name="Area2D" type="Area2D" parent="."] unique_name_in_owner = true collision_layer = 0 diff --git a/scene/entity/note.gd b/scene/entity/note.gd index ba3dfa1e..a59a1f9e 100644 --- a/scene/entity/note.gd +++ b/scene/entity/note.gd @@ -19,13 +19,13 @@ signal read_note dialogue_res = dialogue_c01 "c02": dialogue_res = dialogue_c02 - if is_node_ready(): + if is_node_ready() and Engine.is_editor_hint(): notify_property_list_changed() var note_key := "" @export_enum("none", "notes", "c01", "c02", "c03", "c04", "c05", "c06") var title_filter := "none": set(val): title_filter = val - if is_node_ready(): + if is_node_ready() and Engine.is_editor_hint(): notify_property_list_changed() @onready var sign_mark = %Sign as Sign diff --git a/scene/entity/npc.gd b/scene/entity/npc.gd index 2a5cb58f..27b6fd6b 100644 --- a/scene/entity/npc.gd +++ b/scene/entity/npc.gd @@ -27,6 +27,8 @@ func _init() -> void: # Called when the node enters the scene tree for the first time. func _ready() -> void: + if Engine.is_editor_hint(): + return if animation: play() area2d.body_entered.connect(_reset) diff --git a/scene/entity/old/inspectable.gd b/scene/entity/old/inspectable.gd index 3f02654e..8e9f486d 100644 --- a/scene/entity/old/inspectable.gd +++ b/scene/entity/old/inspectable.gd @@ -9,7 +9,6 @@ extends Sprite2D @export var texture_cover: Texture2D @export var texture_note: Texture2D -@onready var sprite2d = %AnimatedSoundSprite2D as AnimatedSoundSprite2D @onready var sign_mark = %Sign as Sign @onready var area2d = %Area2D as Area2D diff --git a/scene/entity/old/inspectable.tscn b/scene/entity/old/inspectable.tscn index 336978b7..fa372d36 100644 --- a/scene/entity/old/inspectable.tscn +++ b/scene/entity/old/inspectable.tscn @@ -1,12 +1,10 @@ -[gd_scene load_steps=9 format=3 uid="uid://wyj4qdjyn4ql"] +[gd_scene load_steps=7 format=3 uid="uid://wyj4qdjyn4ql"] [ext_resource type="Script" path="res://scene/entity/old/inspectable.gd" id="1_0pc4s"] [ext_resource type="PackedScene" uid="uid://c85t6stvytvjn" path="res://scene/entity/ux/sfx.tscn" id="2_wrnix"] [ext_resource type="AudioStream" uid="uid://dky3j8lwcy5sk" path="res://asset/audio/sfx/ui/物品查看.mp3" id="3_kilnm"] [ext_resource type="Texture2D" uid="uid://bei1s1uucktso" path="res://asset/art/tool/neutral_point_light.webp" id="3_vbivp"] [ext_resource type="PackedScene" uid="uid://c4tipnj1cr1j3" path="res://scene/entity/ux/sign.tscn" id="4_1yty8"] -[ext_resource type="SpriteFrames" uid="uid://b7fhheih1hbvf" path="res://config/animation/entity_sprite_frames.tres" id="7_njjhh"] -[ext_resource type="Script" path="res://scene/entity/ux/animated_sound_sprite_2d.gd" id="8_wntgt"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_4fuic"] resource_local_to_scene = true @@ -35,13 +33,6 @@ energy = 0.0 texture = ExtResource("3_vbivp") texture_scale = 0.5 -[node name="AnimatedSoundSprite2D" type="AnimatedSprite2D" parent="."] -unique_name_in_owner = true -visible = false -sprite_frames = ExtResource("7_njjhh") -animation = &"c00_吕萍_记笔记_right" -script = ExtResource("8_wntgt") - [node name="Area2D" type="Area2D" parent="."] unique_name_in_owner = true collision_layer = 0 diff --git a/scene/entity/pickable.gd b/scene/entity/pickable.gd index 79ad7fe9..2fed54c6 100644 --- a/scene/entity/pickable.gd +++ b/scene/entity/pickable.gd @@ -13,6 +13,8 @@ var played_time = 0 func _ready() -> void: + if Engine.is_editor_hint(): + return area2d.body_entered.connect(_reset) area2d.body_exited.connect(_on_cancel) sign_mark.interacted.connect(_on_interacted) diff --git a/scene/entity/ux/animated_sound_sprite_2d.gd b/scene/entity/ux/animated_sound_sprite_2d.gd deleted file mode 100644 index 0cb84e36..00000000 --- a/scene/entity/ux/animated_sound_sprite_2d.gd +++ /dev/null @@ -1,7 +0,0 @@ -class_name AnimatedSoundSprite2D extends AnimatedSprite2D - - -func play_with_sound(animation_name: String) -> void: - super.play(animation_name) - AudioManager.play_animation_sound(animation_name) - \ No newline at end of file diff --git a/scene/entity/ux/cg_event.gd b/scene/entity/ux/cg_event.gd deleted file mode 100644 index fec0fc77..00000000 --- a/scene/entity/ux/cg_event.gd +++ /dev/null @@ -1,2 +0,0 @@ -extends AnimationPlayer - diff --git a/scene/entity/ux/cg_event.tscn b/scene/entity/ux/cg_event.tscn deleted file mode 100644 index f563ba05..00000000 --- a/scene/entity/ux/cg_event.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://bpouwlfacjjdb"] - -[ext_resource type="Script" path="res://scene/entity/ux/cg_event.gd" id="1_cugx1"] - -[node name="CGEvent" type="AnimationPlayer"] -script = ExtResource("1_cugx1") diff --git a/scene/entity/ux/journal_event.gd b/scene/entity/ux/journal_event.gd deleted file mode 100644 index 487b2843..00000000 --- a/scene/entity/ux/journal_event.gd +++ /dev/null @@ -1,2 +0,0 @@ -extends Node - diff --git a/scene/entity/ux/journal_event.tscn b/scene/entity/ux/journal_event.tscn deleted file mode 100644 index f81e5c46..00000000 --- a/scene/entity/ux/journal_event.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dyelo1dwkvlf"] - -[ext_resource type="Script" path="res://scene/entity/ux/journal_event.gd" id="1_5w7ov"] - -[node name="JournalEvent" type="Node"] -script = ExtResource("1_5w7ov") diff --git a/scene/entity/ux/sfx.gd b/scene/entity/ux/sfx.gd index a542a16c..e255ec40 100644 --- a/scene/entity/ux/sfx.gd +++ b/scene/entity/ux/sfx.gd @@ -10,15 +10,17 @@ class_name Sfx extends AudioStreamPlayer #set(val): #if val and current_files.has(val): #file = val +var sfx: AudioStream var file: String var sfx_root_path = "res://asset/audio/sfx/" var current_files := PackedStringArray() -var sfx: AudioStream func _ready() -> void: - _update_files() + if Engine.is_editor_hint(): + _update_files() + _reload_sfx() bus = &"game_sfx" @@ -88,10 +90,12 @@ func _set(property: StringName, value: Variant) -> bool: return true return false + # func play() -> void: # if sfx: # AudioManager.play_sfx(sfx, volume_db) + # queue free 导致 sfx 无法播放,使用全局声源 func global_play() -> void: if sfx: diff --git a/scene/entity/ux/sign.gd b/scene/entity/ux/sign.gd index 624711a9..80857022 100644 --- a/scene/entity/ux/sign.gd +++ b/scene/entity/ux/sign.gd @@ -151,7 +151,7 @@ func disactivate(_body: Node2D) -> void: func _unhandled_input(event: InputEvent) -> void: - if not enabled: + if Engine.is_editor_hint() or not enabled: return if activated: if event.is_action_pressed("interact"): diff --git a/scene/ground/ground.gd b/scene/ground/ground.gd index dcb8c206..6b8371b8 100644 --- a/scene/ground/ground.gd +++ b/scene/ground/ground.gd @@ -3,7 +3,8 @@ class_name Ground2D extends Node2D @export var scene_name := "" # 用于在 debug 时态下,指定进入的 portal -@export_enum("left", "right", "1", "2", "3", "4", "5", "6", "7", "8", "9") var default_portal := "left" +@export_enum("left", "right", "1", "2", "3", "4", "5", "6", "7", "8", "9") +var default_portal := "left" @export_group("Player", "player_") @export var player_y_fixed := true @export var player_y := 70: @@ -15,6 +16,7 @@ class_name Ground2D extends Node2D set(val): reset_player_pos = false _reset_player_positon() +@export var camera_focus_marker: CameraFocusMarker @export_group("Sound") @export_enum("none", "ghost", "walking", "running", "crawling", "concrete") var footstep_type: String = "concrete": @@ -27,7 +29,6 @@ var footstep_type: String = "concrete": @onready var directional_light := %DirectionalLight2D as DirectionalLight2D @onready var bg_sprite = %BGSprite2D as Sprite2D @onready var foreground = %ParallaxForeground as ParallaxBackground -@onready var camera_focus_marker = %CameraFocusMarker as CameraFocusMarker @onready var camera = %Camera2D as Camera2D @onready var footstep_audio = %FootstepAudioPlayer as RandomAudioStreamPlayer @@ -72,11 +73,12 @@ func _restart_from_main(): # if not main.is_node_ready(): # await main.ready var ground_loader = main.get_node("./GroundLoader") as GroundLoader + # ground_loader.ignore_archive = true ground_loader.ignore_archive = false - ground_loader.archive_scene = scene_name - ground_loader.archive_portal = default_portal - # ground_loader.transition_to_scene(scene_name, default_portal, true) + ground_loader.force_archive_scene = scene_name + ground_loader.force_archive_portal = default_portal get_node("/root").add_child(main) + # ground_loader.transition_to_scene(scene_name, default_portal, true) get_parent().queue_free() diff --git a/scene/ground/ground.tscn b/scene/ground/ground.tscn index 75c91659..983cc832 100644 --- a/scene/ground/ground.tscn +++ b/scene/ground/ground.tscn @@ -14,9 +14,9 @@ func _ready() -> void: layer = GlobalConfig.CANVAS_LAYER_HD_ENTITY " -[node name="Ground" type="Node2D"] +[node name="Ground" type="Node2D" node_paths=PackedStringArray("camera_focus_marker")] script = ExtResource("1_0vrlo") -default_portal = "left" +camera_focus_marker = NodePath("MainPlayer/CameraFocusMarker") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] @@ -50,9 +50,10 @@ portal_name = "right" [node name="AmbientLayer" type="Node2D" parent="."] -[node name="MainPlayer" parent="." instance=ExtResource("3_atha7")] +[node name="MainPlayer" parent="." node_paths=PackedStringArray("camera_marker") instance=ExtResource("3_atha7")] unique_name_in_owner = true position = Vector2(26, 88) +camera_marker = NodePath("CameraFocusMarker") [node name="CameraFocusMarker" parent="MainPlayer" node_paths=PackedStringArray("camera") instance=ExtResource("4_mgk0a")] unique_name_in_owner = true diff --git a/scene/ground/ground_loader.gd b/scene/ground/ground_loader.gd index e16b50d5..511b6356 100644 --- a/scene/ground/ground_loader.gd +++ b/scene/ground/ground_loader.gd @@ -11,8 +11,8 @@ class_name GroundLoader extends Node2D if is_node_ready() and current_scene and entrance_portal: transition_to_scene(current_scene, entrance_portal, true) # 强制覆盖 archive 记录 -@export var archive_scene := "" -@export var archive_portal := "" +@export var force_archive_scene := "" +@export var force_archive_portal := "" @onready var mask_layer := %MaskLayer as CanvasLayer @onready var mask := %Mask as ColorRect @@ -60,15 +60,16 @@ func _read_grounds() -> void: func _load_save(): - if not Engine.is_editor_hint() and ArchiveManager.archive: - if ArchiveManager.archive.current_scene: - archive_scene = ArchiveManager.archive.current_scene - if ArchiveManager.archive.entrance_portal: - archive_portal = ArchiveManager.archive.entrance_portal # 强制覆盖 archive 记录 - if archive_scene or archive_portal: - current_scene = archive_scene - entrance_portal = archive_portal + if force_archive_scene or force_archive_portal: + current_scene = force_archive_scene + entrance_portal = force_archive_portal + return + if not Engine.is_editor_hint(): + if ArchiveManager.archive.current_scene: + current_scene = ArchiveManager.archive.current_scene + if ArchiveManager.archive.entrance_portal: + entrance_portal = ArchiveManager.archive.entrance_portal func _toggle_mask(display: bool, _immediately: bool) -> Tween: @@ -106,8 +107,6 @@ func transition_to_scene(scene_name: String, portal: String, immediately: bool) func _update_archive(): ArchiveManager.archive.current_scene = current_scene ArchiveManager.archive.entrance_portal = entrance_portal - archive_scene = current_scene - archive_portal = entrance_portal func _do_transition(scene_name: String): @@ -145,7 +144,7 @@ func _update_player_position_from_archive(): if ignore_archive or Engine.is_editor_hint(): return var player = SceneManager.get_player() as MainPlayer - if player and ArchiveManager.archive: + if player: # if GlobalConfig.DEBUG: # print("update player position", ArchiveManager.archive.player_global_position) if ArchiveManager.archive.player_global_position_x >= 0: diff --git a/scene/ground/scene/c01/s05_animation.gd b/scene/ground/scene/c01/s05_animation.gd index d564cccd..46182d3c 100644 --- a/scene/ground/scene/c01/s05_animation.gd +++ b/scene/ground/scene/c01/s05_animation.gd @@ -6,7 +6,7 @@ var ambush: Ambush2D var frame: Note2D var paper: Interactable2D var right_door: Portal2D - +var piano: Interactable2D # 覆盖该方法 func _default_data() -> Dictionary: @@ -29,31 +29,42 @@ func _on_deploy_layer_ready() -> void: frame = $"../DeployLayer/画框" paper = $"../DeployLayer/oneshot纸片" right_door = $"../DeployLayer/portal_right" - # 画框 + piano = $"../DeployLayer/钢琴" + # 画框是否已经正位 frame_relocated = ambush.played and ambush.one_shot + # 禁用鸡毛掸子 ambush.enabled = false + # 画框已经正位时,重制画框状态 if frame_relocated: frame.rotation_degrees = 0.0 frame.note_key = "c01_摆正的洋相片" if GlobalConfig.DEBUG: print("重置画框位置") else: + # 画框未正位时,首先允许互动相框 frame.read_note.connect(_on_note_read, CONNECT_ONE_SHOT) ambush.triggered.connect(_on_ambush_triggered) + + # 纸片状态 if frame_relocated: + # 画框已经正位,纸片已经被拾取 if paper.interacted_times > 0: paper.visible = false paper.enabled = false right_door.enabled = true else: + # 画框已经正位,纸片未被拾取,直接掉落 paper.visible = true paper.enabled = true paper.interacted.connect(_on_paper_interacted, CONNECT_ONE_SHOT) else: + # 画框未正位,纸片未掉落 paper.visible = false - paper.enabled = true + paper.enabled = false paper.interacted.connect(_on_paper_interacted, CONNECT_ONE_SHOT) + piano.interacted.connect(_on_piano_interacted) + func _on_note_read(): frame.enabled = false @@ -71,8 +82,8 @@ func _on_ambush_triggered(): func _play_paper_animation(): # 播放纸片动画 - play("纸片飘落") paper.enabled = true + play("纸片飘落") func _on_paper_interacted(): @@ -82,3 +93,6 @@ func _on_paper_interacted(): right_door.enabled = true SceneManager.pop_debug_dialog_info("音效", "开门声") $"../sfx_door_open".play() + +func _on_piano_interacted(): + SceneManager.freeze_and_play(0.0, "钢琴") \ No newline at end of file diff --git a/scene/ground/scene/c01/s05_院长房间.tscn b/scene/ground/scene/c01/s05_院长房间.tscn index 2cf9d385..be129b0d 100644 --- a/scene/ground/scene/c01/s05_院长房间.tscn +++ b/scene/ground/scene/c01/s05_院长房间.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=32 format=3 uid="uid://dlx5xxbg53rb8"] +[gd_scene load_steps=33 format=3 uid="uid://dlx5xxbg53rb8"] [ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_ff4yb"] [ext_resource type="Script" path="res://scene/ground/scene/c01/s05_animation.gd" id="2_j5oim"] @@ -20,6 +20,7 @@ [ext_resource type="AudioStream" uid="uid://dky3j8lwcy5sk" path="res://asset/audio/sfx/ui/物品查看.mp3" id="15_2jvyd"] [ext_resource type="Texture2D" uid="uid://bloct6cpdt2qi" path="res://asset/art/scene/c01/s05_院长房间/l_墙.png" id="16_qh7fg"] [ext_resource type="Texture2D" uid="uid://df30bmtgdoqc3" path="res://asset/art/scene/c01/s05_院长房间/l_窗户光源.png" id="17_qqw2v"] +[ext_resource type="AudioStream" uid="uid://cvttds81trcoc" path="res://asset/audio/sfx/ui/click.wav" id="19_5i4lj"] [ext_resource type="PackedScene" uid="uid://dw0s23v7qmj28" path="res://ui/vertical_label.tscn" id="20_t1dxj"] [ext_resource type="AudioStream" uid="uid://inmdv5gqqius" path="res://asset/audio/sfx/ui/门锁互动.mp3" id="22_4c44k"] [ext_resource type="Script" path="res://scene/entity/ux/sfx.gd" id="23_o1482"] @@ -689,6 +690,14 @@ position = Vector2(414, 51) texture = ExtResource("8_mnduo") one_shot = false +[node name="SfxInvalid" parent="Ground/DeployLayer/钢琴" index="0"] +stream = ExtResource("19_5i4lj") +file = "click.wav" + +[node name="SfxSuccess" parent="Ground/DeployLayer/钢琴" index="1"] +stream = ExtResource("19_5i4lj") +file = "click.wav" + [node name="Sign" parent="Ground/DeployLayer/钢琴" index="2"] offset_left = -1.0 offset_top = -8.0 diff --git a/scene/ground/scene/c02/s03_院子切换.tscn b/scene/ground/scene/c02/s03_院子切换.tscn index 504f8465..643c20c9 100644 --- a/scene/ground/scene/c02/s03_院子切换.tscn +++ b/scene/ground/scene/c02/s03_院子切换.tscn @@ -22,8 +22,9 @@ size = Vector2(40, 70) [node name="S03" type="Node2D"] -[node name="Ground" parent="." instance=ExtResource("1_lheeb")] +[node name="Ground" parent="." node_paths=PackedStringArray("camera_focus_marker") instance=ExtResource("1_lheeb")] scene_name = "c02_s03" +camera_focus_marker = NodePath("MainPlayer/CameraFocusMarker") [node name="AnimationPlayer" parent="Ground" index="0"] script = ExtResource("2_l2oec") diff --git a/scene/player/main_player.gd b/scene/player/main_player.gd index e76598f2..262fc8ee 100644 --- a/scene/player/main_player.gd +++ b/scene/player/main_player.gd @@ -3,6 +3,7 @@ extends CharacterBody2D class_name MainPlayer +@export var camera_marker: CameraFocusMarker @export_enum("吕萍", "吕萍爬行", "吕萍带小猫", "小小蝶") var character := "吕萍": set(val): character = val @@ -191,7 +192,8 @@ func _physics_process(_delta: float) -> void: # drag the camera marker against the player movement # so there will be a better vision in front of the player. func _tweak_camera_marker(): - SceneManager.get_camera_marker().tweak_position(velocity, facing_direction) + if camera_marker != null: + camera_marker.tweak_position(velocity, facing_direction) var lock_mutex = Mutex.new() diff --git a/scene/prop/prop_inventory.gd b/scene/prop/prop_inventory_resource.gd similarity index 100% rename from scene/prop/prop_inventory.gd rename to scene/prop/prop_inventory_resource.gd diff --git a/scene/prop/prop_item.gd b/scene/prop/prop_item_resource.gd similarity index 100% rename from scene/prop/prop_item.gd rename to scene/prop/prop_item_resource.gd diff --git a/ui/button/item_list_modified.tscn b/ui/button/item_list_modified.tscn deleted file mode 100644 index b0fa2d0d..00000000 --- a/ui/button/item_list_modified.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene format=3 uid="uid://782ur70tsfi2"] - -[node name="ItemList" type="ScrollContainer"] -custom_minimum_size = Vector2(50, 0) -offset_right = 68.0 -offset_bottom = 20.0 diff --git a/ui/button/sound_texture_button.gd b/ui/button/sound_texture_button.gd deleted file mode 100644 index ea1e8af5..00000000 --- a/ui/button/sound_texture_button.gd +++ /dev/null @@ -1,37 +0,0 @@ -@tool -extends TextureButton - -class_name SoundTextureButton - -@export var generate_click_mask := false: - set(val): - generate_click_mask = false - if val and texture_normal: - var mask_image := texture_normal.get_image() - texture_click_mask = BitMap.new() - texture_click_mask.create_from_image_alpha(mask_image) -@export var audio_streams := [preload("res://asset/audio/sfx/ui/click.wav")] as Array[AudioStream] -@export var audio_collections = [] as Array[AudioStreamCollection] - - -func _ready(): - if audio_streams: - var collection := AudioStreamCollection.new() - collection.audios = audio_streams - audio_collections.append(collection) - if audio_collections: - #print("sound button load audio_collections into audio_player") - var audio_player := RandomAudioStreamPlayer.new() - audio_player.audio_collections = audio_collections - button_down.connect(audio_player.play_random) - add_child(audio_player) - else: - push_warning("sound button has no audio_collections! ignore initialization of audio_player") - #button_down.connect(_on_press_down) - #button_up.connect(_on_press_up) - -#func _on_press_down(): -#InputUtil.set_cursor_hand_patting() -# -#func _on_press_up(): -#InputUtil.set_cursor_hand_rest() diff --git a/ui/button/sound_texture_button.tscn b/ui/button/sound_texture_button.tscn deleted file mode 100644 index db3bf661..00000000 --- a/ui/button/sound_texture_button.tscn +++ /dev/null @@ -1,8 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://cef5mgr1hgpmr"] - -[ext_resource type="Script" path="res://ui/button/sound_texture_button.gd" id="1_k7j4d"] - -[node name="SoundButton" type="TextureButton"] -size_flags_horizontal = 0 -size_flags_vertical = 0 -script = ExtResource("1_k7j4d") diff --git a/util/lru.gd b/util/lru.gd index 351075d1..0cd33c77 100644 --- a/util/lru.gd +++ b/util/lru.gd @@ -1,4 +1,3 @@ -@tool class_name LRU extends RefCounted # LRU 算法