sfx/sfx2d 在 closeup 时可暂停; 删除【麻将1】
This commit is contained in:
parent
b884cfb054
commit
d3868215d7
@ -21,12 +21,14 @@ func _ready() -> void:
|
|||||||
if Engine.is_editor_hint():
|
if Engine.is_editor_hint():
|
||||||
_reload_groups()
|
_reload_groups()
|
||||||
|
|
||||||
|
|
||||||
func _create_and_add_new_player(index: int) -> void:
|
func _create_and_add_new_player(index: int) -> void:
|
||||||
var sfx_player = RandomAudioStreamPlayer.new()
|
var sfx_player = RandomAudioStreamPlayer.new()
|
||||||
sfx_player.bus = "game_sfx"
|
sfx_player.bus = "game_sfx"
|
||||||
add_child(sfx_player)
|
add_child(sfx_player)
|
||||||
sfx_players.insert(index, sfx_player)
|
sfx_players.insert(index, sfx_player)
|
||||||
|
|
||||||
|
|
||||||
func _reload_groups():
|
func _reload_groups():
|
||||||
VIBE_GROUPS.clear()
|
VIBE_GROUPS.clear()
|
||||||
for group in vibe_group_collection.groups:
|
for group in vibe_group_collection.groups:
|
||||||
@ -45,7 +47,7 @@ func stop_stream(stream: AudioStream, duration := 1.0) -> void:
|
|||||||
sfx_players.remove_at(i)
|
sfx_players.remove_at(i)
|
||||||
_create_and_add_new_player(i)
|
_create_and_add_new_player(i)
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(player, "volume_linear", 0.0, duration)
|
tween.tween_property(player, "volume_linear", 0.01, duration)
|
||||||
tween.tween_callback(player.queue_free)
|
tween.tween_callback(player.queue_free)
|
||||||
else:
|
else:
|
||||||
player.stop()
|
player.stop()
|
||||||
@ -87,7 +89,7 @@ func stop_bgm_music(music_name: StringName, ease_duration := 3.0) -> void:
|
|||||||
audio_player.queue_free()
|
audio_player.queue_free()
|
||||||
else:
|
else:
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_property(audio_player, "volume_linear", 0.0, ease_duration)
|
tween.tween_property(audio_player, "volume_linear", 0.01, ease_duration)
|
||||||
tween.tween_callback(audio_player.queue_free)
|
tween.tween_callback(audio_player.queue_free)
|
||||||
bgm_dict.erase(music_name)
|
bgm_dict.erase(music_name)
|
||||||
else:
|
else:
|
||||||
|
@ -46,6 +46,11 @@ const DIALOG_IGNORE_INPUT = "ignore_input"
|
|||||||
# memory layer: 30
|
# memory layer: 30
|
||||||
const DIALOG_MEM_LAYER = "mem_layer"
|
const DIALOG_MEM_LAYER = "mem_layer"
|
||||||
|
|
||||||
|
# groups
|
||||||
|
const GROUP_GROUND_SFX := "ground_sfx"
|
||||||
|
const GROUP_GROUND_SFX2D := "ground_sfx2d"
|
||||||
|
|
||||||
|
|
||||||
const CHARACTER_COLOR_MAP = {
|
const CHARACTER_COLOR_MAP = {
|
||||||
"default": Color.LIGHT_SEA_GREEN,
|
"default": Color.LIGHT_SEA_GREEN,
|
||||||
"吕萍": Color.ORANGE,
|
"吕萍": Color.ORANGE,
|
||||||
|
@ -12,6 +12,7 @@ const META_ORIGINAL_STREAM = &"original_stream"
|
|||||||
# TODO BGM 过程抑制场景音效;场景音效随玩家运动呼吸 (结合 Sfx2D)
|
# TODO BGM 过程抑制场景音效;场景音效随玩家运动呼吸 (结合 Sfx2D)
|
||||||
# 感应玩家移动:装饰音
|
# 感应玩家移动:装饰音
|
||||||
var default_db := 0.0
|
var default_db := 0.0
|
||||||
|
var default_linear := 1.0
|
||||||
|
|
||||||
# 只有 场景背景音 生效
|
# 只有 场景背景音 生效
|
||||||
var scene_loop := true
|
var scene_loop := true
|
||||||
@ -21,6 +22,7 @@ var scene_sense_player_mov := false
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
bus = &"game_sfx"
|
bus = &"game_sfx"
|
||||||
default_db = volume_db
|
default_db = volume_db
|
||||||
|
default_linear = volume_linear
|
||||||
if Engine.is_editor_hint():
|
if Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
# 记录原 stream
|
# 记录原 stream
|
||||||
@ -106,7 +108,7 @@ func easing_kill(duration: float = 2.0) -> Tween:
|
|||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.bind_node(self)
|
tween.bind_node(self)
|
||||||
if playing:
|
if playing:
|
||||||
tween.tween_property(self, "volume_linear", 0.0, duration)
|
tween.tween_property(self, "volume_linear", 0.01, duration)
|
||||||
tween.tween_callback(stop)
|
tween.tween_callback(stop)
|
||||||
# set volume_db back to default
|
# set volume_db back to default
|
||||||
tween.tween_callback(func(): volume_db = default_db)
|
tween.tween_callback(func(): volume_db = default_db)
|
||||||
@ -164,3 +166,19 @@ func _get(property: StringName) -> Variant:
|
|||||||
return scene_sense_player_mov
|
return scene_sense_player_mov
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
|
var resume_on_close_up_exit := false
|
||||||
|
|
||||||
|
func on_toggle_close_up(display: bool) -> void:
|
||||||
|
if not is_in_group(GlobalConfig.GROUP_GROUND_SFX):
|
||||||
|
return
|
||||||
|
if display:
|
||||||
|
if stream and not stream_paused:
|
||||||
|
resume_on_close_up_exit = true
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "volume_linear", 0.01, 1.0)
|
||||||
|
else:
|
||||||
|
if resume_on_close_up_exit:
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "volume_linear", default_linear, 1.0)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ class_name Sfx2D extends AudioStreamPlayer2D
|
|||||||
|
|
||||||
var timer: Timer
|
var timer: Timer
|
||||||
var default_db := 0.0
|
var default_db := 0.0
|
||||||
|
var default_linear := 1.0
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
bus = &"game_sfx"
|
bus = &"game_sfx"
|
||||||
@ -25,6 +26,7 @@ func _ready() -> void:
|
|||||||
if Engine.is_editor_hint():
|
if Engine.is_editor_hint():
|
||||||
return
|
return
|
||||||
default_db = volume_db
|
default_db = volume_db
|
||||||
|
default_linear = volume_linear
|
||||||
timer = Timer.new()
|
timer = Timer.new()
|
||||||
timer.autostart = autoplay and loop and loop_round_time > 0.0 and not Engine.is_editor_hint()
|
timer.autostart = autoplay and loop and loop_round_time > 0.0 and not Engine.is_editor_hint()
|
||||||
timer.one_shot = false
|
timer.one_shot = false
|
||||||
@ -43,7 +45,6 @@ func _on_ground_transition_pre_paused():
|
|||||||
easing_kill(1.0)
|
easing_kill(1.0)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
if not loop or loop_round_time <= 0.0:
|
if not loop or loop_round_time <= 0.0:
|
||||||
timer.stop()
|
timer.stop()
|
||||||
@ -73,8 +74,24 @@ func easing_kill(duration: float = 2.0) -> Tween:
|
|||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.bind_node(self)
|
tween.bind_node(self)
|
||||||
if playing:
|
if playing:
|
||||||
tween.tween_property(self, "volume_linear", 0.0, duration)
|
tween.tween_property(self, "volume_linear", 0.01, duration)
|
||||||
tween.tween_callback(stop)
|
tween.tween_callback(stop)
|
||||||
# set volume_db back to default
|
# set volume_db back to default
|
||||||
tween.tween_callback(func(): volume_db = default_db)
|
tween.tween_callback(func(): volume_db = default_db)
|
||||||
return tween
|
return tween
|
||||||
|
|
||||||
|
|
||||||
|
var resume_on_close_up_exit := false
|
||||||
|
|
||||||
|
func on_toggle_close_up(display: bool) -> void:
|
||||||
|
if not is_in_group(GlobalConfig.GROUP_GROUND_SFX2D):
|
||||||
|
return
|
||||||
|
if display:
|
||||||
|
if stream and not stream_paused:
|
||||||
|
resume_on_close_up_exit = true
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "volume_linear", 0.01, 1.0)
|
||||||
|
else:
|
||||||
|
if resume_on_close_up_exit:
|
||||||
|
var tween = create_tween()
|
||||||
|
tween.tween_property(self, "volume_linear", default_linear, 1.0)
|
||||||
|
@ -8,6 +8,7 @@ signal exit(arg)
|
|||||||
|
|
||||||
@export var packed_scene: PackedScene
|
@export var packed_scene: PackedScene
|
||||||
@export var quit_closeup_on_cancel := true
|
@export var quit_closeup_on_cancel := true
|
||||||
|
@export var pause_sfx_on_display := false
|
||||||
@export_tool_button("新建特写场景") var create_closeup_scene = _create_scene_with_script
|
@export_tool_button("新建特写场景") var create_closeup_scene = _create_scene_with_script
|
||||||
|
|
||||||
var current_child: Node
|
var current_child: Node
|
||||||
@ -25,6 +26,9 @@ func display() -> void:
|
|||||||
if current_child:
|
if current_child:
|
||||||
return
|
return
|
||||||
if packed_scene:
|
if packed_scene:
|
||||||
|
if pause_sfx_on_display:
|
||||||
|
get_tree().call_group(GlobalConfig.GROUP_GROUND_SFX, "on_toggle_close_up" , true)
|
||||||
|
get_tree().call_group(GlobalConfig.GROUP_GROUND_SFX2D, "on_toggle_close_up" , true)
|
||||||
SceneManager.lock_player(0, action_key)
|
SceneManager.lock_player(0, action_key)
|
||||||
# 展示时,禁用 sign_mark 的输入
|
# 展示时,禁用 sign_mark 的输入
|
||||||
sign_mark.pass_unhandled_input = true
|
sign_mark.pass_unhandled_input = true
|
||||||
@ -38,10 +42,12 @@ func display() -> void:
|
|||||||
|
|
||||||
func _exit(arg = null):
|
func _exit(arg = null):
|
||||||
if current_child:
|
if current_child:
|
||||||
|
if pause_sfx_on_display:
|
||||||
|
get_tree().call_group(GlobalConfig.GROUP_GROUND_SFX, "on_toggle_close_up" , false)
|
||||||
|
get_tree().call_group(GlobalConfig.GROUP_GROUND_SFX2D, "on_toggle_close_up" , false)
|
||||||
SceneManager.unlock_player()
|
SceneManager.unlock_player()
|
||||||
if current_child:
|
remove_child(current_child)
|
||||||
remove_child(current_child)
|
current_child.queue_free()
|
||||||
current_child.queue_free()
|
|
||||||
current_child = null
|
current_child = null
|
||||||
print("quit [", name, "] arg=", arg)
|
print("quit [", name, "] arg=", arg)
|
||||||
exit.emit(arg)
|
exit.emit(arg)
|
||||||
|
@ -77,6 +77,7 @@ func _ready() -> void:
|
|||||||
return
|
return
|
||||||
_setup_scene()
|
_setup_scene()
|
||||||
_setup_runtime()
|
_setup_runtime()
|
||||||
|
_arrange_nodes_to_group(self)
|
||||||
|
|
||||||
|
|
||||||
func _handle_restart() -> void:
|
func _handle_restart() -> void:
|
||||||
@ -103,6 +104,17 @@ func _setup_runtime() -> void:
|
|||||||
SceneManager.toggle_hud_display(display_hud)
|
SceneManager.toggle_hud_display(display_hud)
|
||||||
|
|
||||||
|
|
||||||
|
func _arrange_nodes_to_group(parent: Node) -> void:
|
||||||
|
if not parent:
|
||||||
|
return
|
||||||
|
for c in parent.get_children():
|
||||||
|
_arrange_nodes_to_group(c)
|
||||||
|
if c is Sfx:
|
||||||
|
c.add_to_group(GlobalConfig.GROUP_GROUND_SFX)
|
||||||
|
elif c is Sfx2D:
|
||||||
|
c.add_to_group(GlobalConfig.GROUP_GROUND_SFX2D)
|
||||||
|
|
||||||
|
|
||||||
func _restart_from_main() -> void:
|
func _restart_from_main() -> void:
|
||||||
# _enter_tree, wait for ready
|
# _enter_tree, wait for ready
|
||||||
await ready
|
await ready
|
||||||
|
@ -85,7 +85,7 @@ func _on_ground_ready() -> void:
|
|||||||
$"../DeployLayer/Ambush偷听对话".enabled = false
|
$"../DeployLayer/Ambush偷听对话".enabled = false
|
||||||
eavesdrop_window.visible = false
|
eavesdrop_window.visible = false
|
||||||
|
|
||||||
if ArchiveManager.get_global_value(&"c02_show_grounded_coins"):
|
if ArchiveManager.get_global_value(&"c02_show_grounded_coins") and EventManager.get_chapter_stage() <= 2:
|
||||||
# 奠字 + 纸钱
|
# 奠字 + 纸钱
|
||||||
$"../DeployLayer/新背景_奠".visible = true
|
$"../DeployLayer/新背景_奠".visible = true
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ func _on_ground_ready() -> void:
|
|||||||
ambush_lookback = $"../DeployLayer/Ambush回看洞口"
|
ambush_lookback = $"../DeployLayer/Ambush回看洞口"
|
||||||
gaslight = $"../DeployLayer/灯座Sprite2D/煤油灯"
|
gaslight = $"../DeployLayer/灯座Sprite2D/煤油灯"
|
||||||
boxcat_portal = $"../DeployLayer/portal_1"
|
boxcat_portal = $"../DeployLayer/portal_1"
|
||||||
# 0默认 1拿了麻将 2偷听结束 3已爬出
|
# 0默认 1偷听结束 2已爬出 (不再拿麻将)
|
||||||
if data.hole_interacted_times >= 3:
|
if data.hole_interacted_times >= 2:
|
||||||
setup_rect_after_entered()
|
setup_rect_after_entered()
|
||||||
else:
|
else:
|
||||||
color_mask.color.a = 1.0
|
color_mask.color.a = 1.0
|
||||||
@ -88,8 +88,6 @@ func hole_interacted():
|
|||||||
print("hole_interacted_times=", times)
|
print("hole_interacted_times=", times)
|
||||||
|
|
||||||
if times == 0:
|
if times == 0:
|
||||||
SceneManager.enable_prop_item("prop_麻将")
|
|
||||||
elif times == 1:
|
|
||||||
# 注意:每种情况结束后,都需要将 interacting 设置为 false
|
# 注意:每种情况结束后,都需要将 interacting 设置为 false
|
||||||
interacting = true
|
interacting = true
|
||||||
eavesdrop_start()
|
eavesdrop_start()
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_judx3"]
|
[ext_resource type="PackedScene" uid="uid://dayyx4jerj7io" path="res://scene/ground/ground.tscn" id="1_judx3"]
|
||||||
[ext_resource type="Script" uid="uid://hbbgymjs5xte" path="res://scene/ground/scene/c02/s08_瞎子卧室.gd" id="2_m4uw8"]
|
[ext_resource type="Script" uid="uid://hbbgymjs5xte" path="res://scene/ground/scene/c02/s08_瞎子卧室.gd" id="2_m4uw8"]
|
||||||
[ext_resource type="Texture2D" uid="uid://v3sj36aijq5b" path="res://asset/art/scene/c02/s08_瞎子卧室/bg_瞎子卧室.png" id="3_iares"]
|
[ext_resource type="Texture2D" uid="uid://v3sj36aijq5b" path="res://asset/art/scene/c02/s08_瞎子卧室/bg_瞎子卧室.png" id="3_iares"]
|
||||||
|
[ext_resource type="AudioStream" uid="uid://b2mudqvq1dmng" path="res://asset/audio/sfx/环境音/白噪音/白噪声房间里1.ogg" id="3_nnqdd"]
|
||||||
[ext_resource type="Script" uid="uid://rq6w1vuhuq1m" path="res://scene/entity/audio/sfx.gd" id="3_t3h08"]
|
[ext_resource type="Script" uid="uid://rq6w1vuhuq1m" path="res://scene/entity/audio/sfx.gd" id="3_t3h08"]
|
||||||
[ext_resource type="PackedScene" uid="uid://61pis75a8fdq" path="res://scene/entity/portal.tscn" id="4_1ws4i"]
|
[ext_resource type="PackedScene" uid="uid://61pis75a8fdq" path="res://scene/entity/portal.tscn" id="4_1ws4i"]
|
||||||
[ext_resource type="Texture2D" uid="uid://vqyhgyka3sfo" path="res://asset/art/scene/c02/s08_瞎子卧室/瞎子卧室前景.png" id="4_gx8oy"]
|
[ext_resource type="Texture2D" uid="uid://vqyhgyka3sfo" path="res://asset/art/scene/c02/s08_瞎子卧室/瞎子卧室前景.png" id="4_gx8oy"]
|
||||||
[ext_resource type="AudioStream" uid="uid://o57tyriodr0c" path="res://asset/audio/sfx/环境音/白噪音/白噪声房间里2.ogg" id="4_quq80"]
|
|
||||||
[ext_resource type="AudioStream" uid="uid://dk3e1w3n2snur" path="res://asset/audio/sfx/旧版/c02/纸人出现.ogg" id="5_0qeqe"]
|
[ext_resource type="AudioStream" uid="uid://dk3e1w3n2snur" path="res://asset/audio/sfx/旧版/c02/纸人出现.ogg" id="5_0qeqe"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b5pwb4fm46sad" path="res://asset/art/scene/c02/s08_瞎子卧室/e_墙上纸张.png" id="5_f6mma"]
|
[ext_resource type="Texture2D" uid="uid://b5pwb4fm46sad" path="res://asset/art/scene/c02/s08_瞎子卧室/e_墙上纸张.png" id="5_f6mma"]
|
||||||
[ext_resource type="Texture2D" uid="uid://7ay1ttob8qwm" path="res://asset/art/scene/c02/s08_瞎子卧室/e_床板.png" id="5_vjjde"]
|
[ext_resource type="Texture2D" uid="uid://7ay1ttob8qwm" path="res://asset/art/scene/c02/s08_瞎子卧室/e_床板.png" id="5_vjjde"]
|
||||||
@ -113,7 +113,7 @@ script = ExtResource("2_m4uw8")
|
|||||||
|
|
||||||
[node name="Sfx背景音" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="0"]
|
[node name="Sfx背景音" type="AudioStreamPlayer" parent="Ground/AnimationPlayer" index="0"]
|
||||||
process_mode = 1
|
process_mode = 1
|
||||||
stream = ExtResource("4_quq80")
|
stream = ExtResource("3_nnqdd")
|
||||||
volume_db = -5.0
|
volume_db = -5.0
|
||||||
autoplay = true
|
autoplay = true
|
||||||
bus = &"game_sfx"
|
bus = &"game_sfx"
|
||||||
@ -197,11 +197,13 @@ texture_scale = 0.15
|
|||||||
[node name="Closeup画" parent="Ground/DeployLayer" index="3" instance=ExtResource("10_a48k2")]
|
[node name="Closeup画" parent="Ground/DeployLayer" index="3" instance=ExtResource("10_a48k2")]
|
||||||
position = Vector2(214, -19)
|
position = Vector2(214, -19)
|
||||||
packed_scene = ExtResource("11_mc126")
|
packed_scene = ExtResource("11_mc126")
|
||||||
|
pause_sfx_on_display = true
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="Closeup讨厌他们" parent="Ground/DeployLayer" index="4" instance=ExtResource("10_a48k2")]
|
[node name="Closeup讨厌他们" parent="Ground/DeployLayer" index="4" instance=ExtResource("10_a48k2")]
|
||||||
position = Vector2(214, -19)
|
position = Vector2(214, -19)
|
||||||
packed_scene = ExtResource("16_nub1x")
|
packed_scene = ExtResource("16_nub1x")
|
||||||
|
pause_sfx_on_display = true
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
[node name="灯座Sprite2D" type="Sprite2D" parent="Ground/DeployLayer" index="5"]
|
[node name="灯座Sprite2D" type="Sprite2D" parent="Ground/DeployLayer" index="5"]
|
||||||
|
Loading…
Reference in New Issue
Block a user