细节优化

This commit is contained in:
cakipaul 2025-07-01 01:16:42 +08:00
parent 2e19f12d58
commit 1e335a96c4
24 changed files with 170 additions and 118 deletions

View File

@ -201,7 +201,7 @@
祭台是专门供奉这只大老鼠的? [ID:c02_保卫科祭台os]
鼠歌 <br><br>天地小如喉,<br>红轮自吞吐。<br>多少世间人,<br>都被红轮误。 [ID:c02_保卫科老鼠精]
# c02 小手
...还有什么东西能跟它交换呢? [ID:c02_小手其他交易]
...还有什么东西能跟它交换呢? [ID:]
[ID:c02_小手出现摔倒]
这是什么鬼东西,它是在讨要什么 [ID:]
又来一个! [ID:c02_小手再次出现]

View File

@ -2,6 +2,8 @@ class_name GlobalConfig extends Resource
#const DEBUG = true
static var DEBUG = false
# 与 Editor 编辑器有 Debugger 连接
# static var EDITOR = false
# .res would be binary encoded, .tres is text encoded
const RES_FILE_FORMAT = ".tres"

View File

@ -54,7 +54,7 @@ func c02_fire_count_down_try_start():
func _on_c02_fire_count_down_timeout():
SceneManager.lock_player(0)
SceneManager.lock_player()
SceneManager.pop_debug_dialog_info("音效", "【重开】霸凌救小蝉倒计时")
c02_fire_count_down_timer.stop()
AudioManager.stop_bgm_music("霸凌救小蝉倒计时")

View File

@ -60,11 +60,11 @@ var current_animation_config: Dictionary
# # animation -> {frame -> {shadow polygon}}
# var animation_shadow_polygons = {}
func _ready() -> void:
os_pivot.os_finished.connect(os_finished.emit)
sprite.visible = not hide_sprite
light.enabled = enable_light
_check_character_runtime_status()
if not Engine.is_editor_hint():
os_pivot.os_finished.connect(os_finished.emit)
footstep_timer.timeout.connect(_on_footstep_timer_timeout)
footstep_timer.stop()
sprite.animation_finished.connect(animation_finished.emit)
@ -205,7 +205,6 @@ func _get_speed(direction: Vector2) -> Vector2:
func _physics_process(_delta: float) -> void:
if Engine.is_editor_hint() or (reenter_lock and reenter_lock.is_frozen()):
# or not is_visible_in_tree()
velocity = Vector2.ZERO
return
var x_direction := Input.get_axis("left", "right")
@ -378,7 +377,7 @@ func walk_to(global_pos: Vector2) -> Tween:
if time_cost >= 0.05:
if GlobalConfig.DEBUG:
print("walk_to start. lock player. time_cost:", time_cost)
SceneManager.lock_player(0, 3, false)
SceneManager.lock_player()
var direction = facing_direction
if global_pos.x < global_position.x:
direction.x = -1.0

View File

@ -72,6 +72,8 @@ shape = SubResource("RectangleShape2D_jwk3s")
[node name="OSPivot" parent="." instance=ExtResource("2_jgqhw")]
unique_name_in_owner = true
offset_top = -120.0
offset_bottom = -120.0
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
unique_name_in_owner = true

View File

@ -54,6 +54,7 @@ func freeze(duration := 0.0) -> void:
_freeze_requests += 1
if GlobalConfig.DEBUG:
print("[Lock] Freeze applied: ", _freeze_requests)
print("freeze from: ", _get_stack_info())
freeze_changed.emit(_freeze_requests, true)
@ -70,6 +71,7 @@ func release() -> void:
_freeze_requests = 0
if GlobalConfig.DEBUG:
print("[Lock] Release applied: ", _freeze_requests)
print("release from: ", _get_stack_info())
freeze_changed.emit(_freeze_requests, false)
@ -80,6 +82,7 @@ func hold(duration := 0.0) -> void:
_hold_requests += 1
if GlobalConfig.DEBUG:
print("[Lock] Hold applied: ", _hold_requests)
print("hold from: ", _get_stack_info())
hold_changed.emit(_hold_requests, true)
@ -96,6 +99,7 @@ func unhold() -> void:
_hold_requests = 0
if GlobalConfig.DEBUG:
print("[Lock] Unhold applied: ", _hold_requests)
print("unhold from: ", _get_stack_info())
hold_changed.emit(_hold_requests, false)
@ -124,6 +128,7 @@ func lock_all(duration := 0.0) -> void:
_freeze_requests += 1
if GlobalConfig.DEBUG:
prints("[Lock] LockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
print("lock_all from: ", _get_stack_info())
hold_changed.emit(_hold_requests, true)
freeze_changed.emit(_freeze_requests, true)
@ -153,7 +158,22 @@ func unlock_all() -> void:
hold_changed.emit(_hold_requests, false)
if GlobalConfig.DEBUG:
prints("[Lock] UnlockAll applied (hold, freeze): ", _hold_requests, _freeze_requests)
print("unlock_all from: ", _get_stack_info())
func _to_string() -> String:
return "[Lock] Freeze: %d, Hold: %d" % [_freeze_requests, _hold_requests]
func _get_stack_info() -> String:
var stack = get_stack()
# 0: [self] _get_stack_info();
# 1: [caller] i.e. print("...", _get_stack_info());
# 2: scene_manager.gd
# 3: target caller
# {function:bar, line:12, source:res://script.gd}
if len(stack) > 3:
return stack[3].source.get_file() + ":" + stack[3].function + ":" + str(stack[3].line)
elif len(stack) > 2:
return stack[2].source.get_file() + ":" + stack[2].function + ":" + str(stack[2].line)
return ""

View File

@ -20,7 +20,7 @@ var scene_sense_player_mov := false
func _ready() -> void:
bus = &"game_sfx"
default_db = volume_db
process_mode = Node.PROCESS_MODE_PAUSABLE
process_mode = Node.PROCESS_MODE_INHERIT
if Engine.is_editor_hint():
return
finished.connect(_on_finished)

View File

@ -48,10 +48,10 @@ tracks/0/path = NodePath("SpeakingSign2D/Sprite2D:offset")
tracks/0/interp = 2
tracks/0/loop_wrap = false
tracks/0/keys = {
"times": PackedFloat32Array(0, 1, 1.5),
"transitions": PackedFloat32Array(1, 1, 1),
"times": PackedFloat32Array(0, 1.5),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(60, 0), Vector2(0, 0), Vector2(0, 0)]
"values": [Vector2(100, 0), Vector2(60, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
@ -109,7 +109,6 @@ dialogue_title = ""
[node name="Sfx" type="AudioStreamPlayer" parent="."]
unique_name_in_owner = true
process_mode = 1
stream = ExtResource("3_7lwt5")
bus = &"game_sfx"
script = ExtResource("4_j5svs")

View File

@ -52,7 +52,6 @@ camera_marker = NodePath("../CameraFocusMarker")
[node name="CameraFocusMarker" parent="." node_paths=PackedStringArray("focusing_node") instance=ExtResource("4_mgk0a")]
unique_name_in_owner = true
position = Vector2(26, 88)
focusing_node = NodePath("../MainPlayer")
[node name="ParallaxForeground" type="ParallaxBackground" parent="."]

View File

@ -21,7 +21,6 @@ script = ExtResource("2_4kx83")
oneshot_animation = ""
[node name="背景音效" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="0"]
process_mode = 1
stream = ExtResource("3_6prdo")
volume_db = -7.924
autoplay = true

View File

@ -158,21 +158,18 @@ script = ExtResource("2_espm6")
oneshot_animation = ""
[node name="黄包车Sfx" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="0"]
process_mode = 1
stream = ExtResource("3_ummkx")
volume_db = -7.924
bus = &"game_sfx"
script = ExtResource("3_vx53v")
[node name="chapter_sfx" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="1"]
process_mode = 1
stream = ExtResource("5_amglq")
volume_db = -5.0
bus = &"game_sfx"
script = ExtResource("3_vx53v")
[node name="黄包车背景音效" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="2"]
process_mode = 1
stream = SubResource("AudioStreamSynchronized_s11la")
autoplay = true
bus = &"game_sfx"
@ -333,7 +330,7 @@ position = Vector2(-59, 48)
shape = SubResource("RectangleShape2D_jd8t2")
[node name="路灯序列2" type="Node2D" parent="Ground/AmbientLayer" index="1"]
position = Vector2(7304, 8)
position = Vector2(7268, 10)
script = ExtResource("9_6p5hp")
total_distance = 4000.0
@ -342,7 +339,7 @@ trigger_mode = "area_enter"
hook_method = "sun_fall"
[node name="路灯" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(333.333, 0)
position = Vector2(307.692, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -366,7 +363,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯2" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(666.667, 0)
position = Vector2(615.385, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -390,7 +387,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯3" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(1000, 0)
position = Vector2(923.077, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -414,7 +411,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯4" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(1333.33, 0)
position = Vector2(1230.77, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -438,7 +435,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯5" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(1666.67, 0)
position = Vector2(1538.46, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -462,7 +459,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯6" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(2000, 0)
position = Vector2(1846.15, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -486,7 +483,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯7" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(2333.33, 0)
position = Vector2(2153.85, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -510,7 +507,7 @@ position = Vector2(-59, 48)
shape = SubResource("RectangleShape2D_jd8t2")
[node name="路灯8" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(2666.67, 0)
position = Vector2(2461.54, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -534,7 +531,7 @@ position = Vector2(-59, 48)
shape = SubResource("RectangleShape2D_jd8t2")
[node name="路灯9" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(3000, 0)
position = Vector2(2769.23, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -558,7 +555,7 @@ texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯10" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(3333.33, 0)
position = Vector2(3076.92, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -581,8 +578,32 @@ shadow_color = Color(0, 0, 0, 1)
texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯12" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(3384.62, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
[node name="PointLight2D1" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯12"]
energy = 5.0
shadow_color = Color(0, 0, 0, 1)
texture = ExtResource("11_2w2ir")
height = 40.0
[node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯12"]
position = Vector2(-59, 48)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯12/Area2D"]
shape = SubResource("RectangleShape2D_jd8t2")
[node name="PointLight2D2" type="PointLight2D" parent="Ground/AmbientLayer/路灯序列2/路灯12"]
position = Vector2(0, -52)
energy = 2.5
shadow_color = Color(0, 0, 0, 1)
texture = ExtResource("17_s11la")
height = 40.0
[node name="路灯11" type="Sprite2D" parent="Ground/AmbientLayer/路灯序列2"]
position = Vector2(3666.67, 0)
position = Vector2(3692.31, 0)
texture = ExtResource("9_u6881")
script = ExtResource("11_6p5hp")
@ -593,7 +614,7 @@ texture = ExtResource("11_2w2ir")
height = 40.0
[node name="Area2D" type="Area2D" parent="Ground/AmbientLayer/路灯序列2/路灯11"]
position = Vector2(-159.667, 49)
position = Vector2(-149.308, 47)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/AmbientLayer/路灯序列2/路灯11/Area2D"]
shape = SubResource("RectangleShape2D_jd8t2")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://bbs7yy5aofw1v"]
[gd_scene load_steps=12 format=3 uid="uid://bbs7yy5aofw1v"]
[ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_c4tdi"]
[ext_resource type="Script" uid="uid://jkselt4d5q4r" path="res://scene/ground/scene/c02/s01_公寓门口.gd" id="2_jfumy"]
@ -9,13 +9,9 @@
[ext_resource type="Texture2D" uid="uid://qls0yc054048" path="res://asset/art/scene/c02/小蝉寻人启事/e_寻人启事残破.png" id="8_j2ctx"]
[ext_resource type="Texture2D" uid="uid://cuyfloebe2mht" path="res://asset/art/scene/c02/小蝉寻人启事/ux_寻人启事残破.png" id="9_bhi7l"]
[ext_resource type="Texture2D" uid="uid://cg1ey0l55acvs" path="res://asset/art/scene/c01/s09_黄包车长场景/e_单个路灯.png" id="9_nglqu"]
[ext_resource type="Script" uid="uid://celg5or3mpla0" path="res://scene/ground/script/c01/s11_黄包车路灯.gd" id="10_acjhe"]
[ext_resource type="Texture2D" uid="uid://cgsq1im2q63f8" path="res://asset/art/scene/c01/s09_黄包车长场景/e_路灯灯芯.png" id="11_ev3cr"]
[ext_resource type="Texture2D" uid="uid://cylsq5cvhlp18" path="res://asset/art/tool/point_light.png" id="12_71mn6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_nglqu"]
size = Vector2(200, 100)
[node name="S01" type="Node2D"]
[node name="Ground" parent="." instance=ExtResource("1_c4tdi")]
@ -64,7 +60,6 @@ content_key = "c02_寻人启事_残破"
[node name="路灯" type="Sprite2D" parent="Ground/DeployLayer" index="4"]
position = Vector2(218, -10)
texture = ExtResource("9_nglqu")
script = ExtResource("10_acjhe")
[node name="PointLight2D1" type="PointLight2D" parent="Ground/DeployLayer/路灯"]
energy = 5.0
@ -72,12 +67,6 @@ shadow_color = Color(0, 0, 0, 1)
texture = ExtResource("11_ev3cr")
height = 40.0
[node name="Area2D" type="Area2D" parent="Ground/DeployLayer/路灯"]
position = Vector2(0, 49)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/路灯/Area2D"]
shape = SubResource("RectangleShape2D_nglqu")
[node name="PointLight2D2" type="PointLight2D" parent="Ground/DeployLayer/路灯"]
position = Vector2(0, -52)
energy = 2.0
@ -88,7 +77,6 @@ height = 40.0
[node name="路灯2" type="Sprite2D" parent="Ground/DeployLayer" index="5"]
position = Vector2(508, -9)
texture = ExtResource("9_nglqu")
script = ExtResource("10_acjhe")
[node name="PointLight2D1" type="PointLight2D" parent="Ground/DeployLayer/路灯2"]
energy = 5.0
@ -96,12 +84,6 @@ shadow_color = Color(0, 0, 0, 1)
texture = ExtResource("11_ev3cr")
height = 40.0
[node name="Area2D" type="Area2D" parent="Ground/DeployLayer/路灯2"]
position = Vector2(0, 49)
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/路灯2/Area2D"]
shape = SubResource("RectangleShape2D_nglqu")
[node name="PointLight2D2" type="PointLight2D" parent="Ground/DeployLayer/路灯2"]
position = Vector2(0, -52)
energy = 2.0

View File

@ -65,7 +65,6 @@ data = {
oneshot_animation = ""
[node name="冷飕飕Sfx" parent="Ground/AnimationPlayer" index="0" instance=ExtResource("3_fvldj")]
process_mode = 1
stream = ExtResource("4_36l5t")
volume_db = -10.0
mode = "交互与效果音"
@ -161,7 +160,6 @@ shape = SubResource("RectangleShape2D_mjnwv")
disabled = true
[node name="Sfx" type="AudioStreamPlayer" parent="Ground/DeployLayer/Ambush纸人"]
process_mode = 1
stream = ExtResource("11_u68d7")
bus = &"game_sfx"
script = ExtResource("14_jg8g0")

View File

@ -14,29 +14,28 @@ func _ready() -> void:
func _on_ground_ready() -> void:
_intro.call_deferred()
func _intro():
SceneManager.get_lock().lock_all()
# var player = SceneManager.get_player() as MainPlayer
var player = %MainPlayer as MainPlayer
player.hide_sprite = true
player.position.x = 231.0
player.set_facing_direction(Vector2.RIGHT)
var anim = $"../DeployLayer/小猫初始动画" as AnimatedSprite2D
if not ArchiveManager.get_global_value(&"c02_boxcat_skip_intro"):
print("[盒子猫] intro start")
SceneManager.lock_player()
player.hide_sprite = true
player.position.x = 231.0
var layer = $"../盒子猫CanvasLayer"
layer.disable_crawl = true
var duration = layer.show_cat_duration
await get_tree().create_timer(duration).timeout
$"Sfx钻盒子演出".play()
anim.play()
var camera = SceneManager.get_camera_marker()
create_tween().tween_property(camera, "force_offset", Vector2.ZERO, 1.0)
anim.play()
await anim.animation_finished
layer.disable_crawl = false
player.hide_sprite = false
SceneManager.unlock_player()
print("[盒子猫] intro end")
anim.visible = false
player.hide_sprite = false
SceneManager.get_lock().unlock_all()
SceneManager.pop_center_notification(tr("ui_boxcat_press_s"))
ArchiveManager.archive.set_global_entry(&"c02_boxcat_skip_intro", true)

View File

@ -22,7 +22,6 @@ script = ExtResource("2_7ah3n")
oneshot_animation = ""
[node name="Sfx钻盒子演出" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="0"]
process_mode = 1
stream = ExtResource("3_72mc1")
bus = &"game_sfx"
script = ExtResource("4_r3hvb")

File diff suppressed because one or more lines are too long

View File

@ -213,7 +213,7 @@ func _on_interacted() -> void:
await Util.wait(1.5)
coin.visible = true
if not ArchiveManager.get_global_value(&"c02_little_hand_dropped_tin"):
SceneManager.pop_os_with_str("c02_小手要东西")
SceneManager.pop_os_with_str("c02_小手其他交易")
ArchiveManager.set_global_entry(&"c02_little_hand_dropped_tin", true)
# 是否允许老虎钳换弹珠

View File

@ -32,57 +32,66 @@ func _ready():
var down_pressing = false:
set(val):
# print("down_pressing: ", val)
if down_pressing == val:
return
down_pressing = val
_try_toggle_crawl()
# 用来判断盒子猫是否在下蹲状态
var crawling = false:
set(val):
crawling = val
if crawling:
$"Sfx翻身躲藏".play()
else:
$"Sfx退出躲藏".play()
locking = crawling
# print("crawling: ", val)
if val != down_pressing:
if crawling != down_pressing:
# 执行结束后,如果发现不一致,尝试切换
# print("crawling mismatch, swtich to: ", down_pressing)
# 需要重置 tween
crawling_toggle_tween = null
_try_toggle_crawl()
var crawling_toggle_tween: Tween
var locking = false:
set(val):
if locking == val:
return
locking = val
if locking:
SceneManager.lock_player()
else:
SceneManager.unlock_player()
var _toggle_mutex = Mutex.new()
func _try_toggle_crawl():
_toggle_mutex.lock()
if down_pressing == crawling:
_toggle_mutex.unlock()
return
if crawling_toggle_tween and crawling_toggle_tween.is_valid():
# print("tweening, skip.")
_toggle_mutex.unlock()
return
crawling_toggle_tween = create_tween()
var crawl = down_pressing
if crawl:
SceneManager.freeze_player(0)
locking = true
SceneManager.player_action(7)
$"Sfx翻身躲藏".play()
else:
SceneManager.player_action(8, true)
crawling_toggle_tween.tween_interval(0.4)
if not crawl:
crawling_toggle_tween.tween_callback(SceneManager.release_player)
$"Sfx退出躲藏".play()
crawling_toggle_tween.tween_interval(0.3)
crawling_toggle_tween.tween_callback(func(): crawling = crawl)
_toggle_mutex.unlock()
func _unhandled_input(event: InputEvent) -> void:
if disable_crawl:
return
if event.is_action_pressed("down"):
get_viewport().set_input_as_handled()
if not down_pressing:
down_pressing = true
down_pressing = true
elif event.is_action_released("down"):
get_viewport().set_input_as_handled()
if down_pressing:
down_pressing = false
down_pressing = false
func show_footprint():

View File

@ -13,19 +13,16 @@
[ext_resource type="Texture2D" uid="uid://dx3i8mchgux1d" path="res://asset/art/scene/c02/s12_to_s17_盒子猫/ux_纸张.png" id="6_rxlkc"]
[node name="盒子猫CanvasLayer" type="CanvasLayer"]
process_mode = 1
layer = 0
script = ExtResource("1_ygosu")
[node name="Sfx翻身躲藏" type="AudioStreamPlayer" parent="."]
process_mode = 1
stream = ExtResource("2_8mjri")
bus = &"game_sfx"
script = ExtResource("3_3ukbg")
metadata/_custom_type_script = "uid://rq6w1vuhuq1m"
[node name="Sfx退出躲藏" type="AudioStreamPlayer" parent="."]
process_mode = 1
stream = ExtResource("4_0rwiy")
bus = &"game_sfx"
script = ExtResource("3_3ukbg")

View File

@ -41,8 +41,6 @@ var move_and_detact = false:
func _ready() -> void:
SceneManager.get_ground().ready.connect(_on_ground_ready)
# 抓盒子猫后,传送回初始场景,跳过其 intro 过程(从纸面逐渐进入黑板粉笔空间)
ArchiveManager.archive.set_global_entry(&"c02_boxcat_skip_intro", true)
func _on_ground_ready():

View File

@ -3,8 +3,6 @@
# A draggable item in the game that can be picked up and displayed with an outline effect.
class_name Draggable2D extends Area2D
static var current_focusing_item = ""
# pass self
signal picked(node: Draggable2D)
signal dropped(node: Draggable2D)
@ -44,12 +42,6 @@ func _ready() -> void:
if Engine.is_editor_hint():
return
_toggle_outline(false)
var collision2d = get_node_or_null("CollisionShape2D")
if not collision2d:
push_error("CollisionShape2D node not found in Draggable2D", self)
collision2d = CollisionShape2D.new()
add_child(collision2d)
collision2d.shape = RectangleShape2D.new()
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
@ -58,23 +50,43 @@ func _ready() -> void:
var holding = false
var touching = false
static var current_focusing_item = "":
set(val):
current_focusing_item = val
if GlobalConfig.DEBUG:
print("current_focusing_item=", current_focusing_item)
static var pending_enter_callables := [] as Array[Callable]
func _on_mouse_entered() -> void:
func is_focused() -> bool:
return current_focusing_item == item_name
func _on_mouse_entered() -> bool:
touching = true
if freezing or not is_visible_in_tree():
return
return false
if holding or is_focused():
return true
# 尝试获得 current_focusing_item
if current_focusing_item != "":
return
if not pending_enter_callables.has(_on_mouse_entered):
pending_enter_callables.append(_on_mouse_entered)
return false
current_focusing_item = item_name
touching = true
_toggle_outline(true)
return true
func _on_mouse_exited() -> void:
# frezzing 不影响 mouse exited
if touching and not holding:
current_focusing_item = ""
touching = false
pending_enter_callables.erase(_on_mouse_entered)
# frezzing 不影响 mouse exited
if is_focused():
current_focusing_item = ""
for c in pending_enter_callables:
if c.call():
break
_toggle_outline(false)
@ -112,7 +124,6 @@ func _try_pick() -> void:
# 作为按钮,发送 picked 信号
picked.emit(self)
var tween = create_tween()
tween.tween_property(sprite.material, "shader_parameter/alpha_ratio", 0.5, 0.15)
tween.tween_property(sprite.material, "shader_parameter/alpha_ratio", 1.0, 0.15)
return
if current_focusing_item != item_name:
@ -131,7 +142,7 @@ func _drop() -> void:
holding = false
# z_index -= 1
dropped.emit(self)
if touching:
if is_focused():
_toggle_outline(true)
else:
# not touching but dropped, remove current_focusing_item if any

View File

@ -103,12 +103,13 @@ func _toggle_side_handle_outline(display: bool):
func _on_box_picked(_node):
sfx_open_lid.play()
# 1关闭 2打开 3放入小蝉人偶 4全部放置正确可摇手柄 5已播放完成
if stage == 1:
_chechout_stage(2)
else:
box_closed.visible = false
box_broken.visible = true
box_closed.hide()
box_broken.show()
if pic:
pic.visible = true

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=46 format=3 uid="uid://beleib3mmu0af"]
[gd_scene load_steps=47 format=3 uid="uid://beleib3mmu0af"]
[ext_resource type="Texture2D" uid="uid://2xbl572hv2qf" path="res://asset/art/little_game/八音盒/背景.png" id="1_j0wst"]
[ext_resource type="Script" uid="uid://bian8ga7cet8k" path="res://scene/little_game/八音盒/八音盒.gd" id="2_opptd"]
@ -12,6 +12,7 @@
[ext_resource type="AudioStream" uid="uid://5jk88e0cncy8" path="res://asset/audio/sfx/交互/序章/04_书店内_关门.wav" id="6_rdaqv"]
[ext_resource type="Texture2D" uid="uid://oe61u43dmtd2" path="res://asset/art/little_game/八音盒/插销动画/插销-5.png" id="7_4e3ey"]
[ext_resource type="AudioStream" uid="uid://ehgd455wq8to" path="res://asset/audio/sfx/交互/序章/03_书店外黄昏_开门.wav" id="7_rriyt"]
[ext_resource type="AudioStream" uid="uid://dkjpyf2pvh33t" path="res://asset/audio/sfx/game/八音盒/八音盒打开.mp3" id="7_wq2wm"]
[ext_resource type="Texture2D" uid="uid://c76aw8sjvkj5y" path="res://asset/art/little_game/八音盒/插销动画/插销-6.png" id="8_5yute"]
[ext_resource type="Texture2D" uid="uid://dxt5sf8eucx8q" path="res://asset/art/little_game/八音盒/插销动画/插销-7.png" id="9_hwyly"]
[ext_resource type="Texture2D" uid="uid://cxdsucu5wi464" path="res://asset/art/little_game/八音盒/插销动画/插销-8.png" id="10_j5b7e"]
@ -158,7 +159,7 @@ stream = ExtResource("6_rdaqv")
bus = &"game_sfx"
[node name="OpenLid" type="AudioStreamPlayer" parent="."]
stream = ExtResource("6_rdaqv")
stream = ExtResource("7_wq2wm")
bus = &"game_sfx"
[node name="CloseLid" type="AudioStreamPlayer" parent="."]
@ -185,9 +186,10 @@ sprite_frames = SubResource("SpriteFrames_t7gu7")
centered = false
[node name="ClosedBox" parent="All" instance=ExtResource("16_h88gi")]
visible = false
position = Vector2(277, 194.5)
act_as_button = true
item_name = "照片"
item_name = "盒子"
sprite_offset = Vector2(3, -35)
texture = ExtResource("22_rdaqv")
limit_rect = Rect2(150, 150, 220, 70)
@ -274,11 +276,12 @@ centered = false
[node name="Draggable抽屉" parent="All/BrokenBox" instance=ExtResource("16_h88gi")]
position = Vector2(350, 210)
act_as_button = true
item_name = "抽屉"
texture = ExtResource("28_b3w8p")
limit_rect = Rect2(150, 150, 220, 70)
[node name="CollisionShape2D" type="CollisionShape2D" parent="All/BrokenBox/Draggable抽屉"]
position = Vector2(-12, 8)
position = Vector2(-12, 9)
shape = SubResource("RectangleShape2D_cbhp3")
[node name="Draggable照片" parent="All" instance=ExtResource("16_h88gi")]
@ -293,6 +296,7 @@ position = Vector2(6.4373e-06, -9.53674e-07)
polygon = PackedVector2Array(31.5, -37.5, 29.7, -38, 18.4, -38, -19.7, -28.9, -26, -32, -30.7, -32, -32.5, -28.4, -32.5, -23.2, -24.5, -15.2, -24.5, -9.6, -20.5, -8.3, -20.5, 4.5, -17.7, 10, -14.5, 30.3, -14.5, 32, -10.5, 35, -10.5, 37, 3.3, 37, 4.5, 26.1, 6.2, 25, 9.3, 25, 7.5, 19.6, 10.6, 14, 13.1, 14, 10.5, 4, 10.5, 3.2, 21, -2, 23.6, -2, 31.6, -14, 32.5, -14, 32.5, -22.4, 31.5, -28.3)
[node name="Drawer" type="Node2D" parent="All"]
visible = false
position = Vector2(20.5, 0)
[node name="BoxDrawer" type="Sprite2D" parent="All/Drawer"]

View File

@ -16,7 +16,6 @@ layer = 30
script = ExtResource("1_7u4nq")
[node name="Sfx打开" type="AudioStreamPlayer" parent="."]
process_mode = 1
stream = ExtResource("2_6hxkf")
volume_db = -5.0
bus = &"game_sfx"
@ -24,7 +23,6 @@ script = ExtResource("3_kn03d")
metadata/_custom_type_script = "uid://rq6w1vuhuq1m"
[node name="Sfx关闭" type="AudioStreamPlayer" parent="."]
process_mode = 1
stream = ExtResource("4_n2b1f")
volume_db = -5.0
bus = &"game_sfx"