优化传送音效
This commit is contained in:
parent
27b9a5a50f
commit
77a180091c
@ -10,10 +10,14 @@ extends Sprite2D
|
|||||||
@export var target_scene := "c02_s00"
|
@export var target_scene := "c02_s00"
|
||||||
@export_enum("none", "left", "right", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
@export_enum("none", "left", "right", "1", "2", "3", "4", "5", "6", "7", "8", "9")
|
||||||
var target_portal := "none"
|
var target_portal := "none"
|
||||||
|
@export_enum("door", "channel") var sound_effect := "door"
|
||||||
|
|
||||||
@onready var sign_mark = %Sign as Sprite2D
|
@onready var sign_mark = %Sign as Sprite2D
|
||||||
@onready var area2d = %Area2D as Area2D
|
@onready var area2d = %Area2D as Area2D
|
||||||
|
|
||||||
|
var sfx_door := preload("res://config/audio/action/action_door_open.tres")
|
||||||
|
var sfx_channel := preload("res://config/audio/action/action_book_open.tres")
|
||||||
|
|
||||||
var activated := false
|
var activated := false
|
||||||
var action_times := 0
|
var action_times := 0
|
||||||
|
|
||||||
@ -25,6 +29,12 @@ func _ready() -> void:
|
|||||||
area2d.body_exited.connect(_on_cancel)
|
area2d.body_exited.connect(_on_cancel)
|
||||||
sign_mark.interacted.connect(_on_interacted)
|
sign_mark.interacted.connect(_on_interacted)
|
||||||
sign_mark.cancel.connect(_on_cancel)
|
sign_mark.cancel.connect(_on_cancel)
|
||||||
|
# sound effect
|
||||||
|
if sound_effect == "door":
|
||||||
|
sign_mark.audio_collection = sfx_door
|
||||||
|
elif sound_effect == "channel":
|
||||||
|
sign_mark.audio_collection = sfx_channel
|
||||||
|
# show or hide sign
|
||||||
if target_portal == "none":
|
if target_portal == "none":
|
||||||
sign_mark.show_sign = false
|
sign_mark.show_sign = false
|
||||||
|
|
||||||
@ -62,7 +72,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
action_times += 1
|
action_times += 1
|
||||||
elif event.is_action("right"):
|
elif event.is_action("right"):
|
||||||
action_times = 0
|
action_times = 0
|
||||||
if action_times >= 10:
|
if action_times >= 7:
|
||||||
activated = false
|
activated = false
|
||||||
action_times = 0
|
action_times = 0
|
||||||
if sign_mark.random_audio_player:
|
if sign_mark.random_audio_player:
|
||||||
@ -73,7 +83,7 @@ func _input(event: InputEvent) -> void:
|
|||||||
action_times += 1
|
action_times += 1
|
||||||
elif event.is_action("left"):
|
elif event.is_action("left"):
|
||||||
action_times = 0
|
action_times = 0
|
||||||
if action_times >= 10:
|
if action_times >= 7:
|
||||||
activated = false
|
activated = false
|
||||||
action_times = 0
|
action_times = 0
|
||||||
if sign_mark.random_audio_player:
|
if sign_mark.random_audio_player:
|
||||||
|
@ -15,7 +15,12 @@ extends Node2D
|
|||||||
volume_db = val
|
volume_db = val
|
||||||
if random_audio_player:
|
if random_audio_player:
|
||||||
random_audio_player.volume_db = volume_db
|
random_audio_player.volume_db = volume_db
|
||||||
@export var audio_collection: AudioStreamCollection
|
@export var audio_collection: AudioStreamCollection:
|
||||||
|
set(val):
|
||||||
|
audio_collection = val
|
||||||
|
if random_audio_player:
|
||||||
|
random_audio_player.audio_collections.clear()
|
||||||
|
random_audio_player.audio_collections.append(audio_collection)
|
||||||
|
|
||||||
signal interacted
|
signal interacted
|
||||||
signal cancel
|
signal cancel
|
||||||
|
@ -42,10 +42,11 @@ func play_footstep_sound() -> void:
|
|||||||
func transition_to_scene(key: String, portal: String, load_save := false) -> void:
|
func transition_to_scene(key: String, portal: String, load_save := false) -> void:
|
||||||
var scene_path = ground_dict[key]
|
var scene_path = ground_dict[key]
|
||||||
if scene_path:
|
if scene_path:
|
||||||
|
var scene = load(scene_path).instantiate()
|
||||||
current_scene = key
|
current_scene = key
|
||||||
entrance_portal = portal
|
entrance_portal = portal
|
||||||
if load_save:
|
if load_save:
|
||||||
_do_transition(scene_path)
|
_do_transition(scene)
|
||||||
# 更新玩家位置
|
# 更新玩家位置
|
||||||
_update_player_position()
|
_update_player_position()
|
||||||
else:
|
else:
|
||||||
@ -55,8 +56,8 @@ func transition_to_scene(key: String, portal: String, load_save := false) -> voi
|
|||||||
player.action_locked = true
|
player.action_locked = true
|
||||||
#TODO 转场效果
|
#TODO 转场效果
|
||||||
#
|
#
|
||||||
tween.tween_interval(1.0)
|
tween.tween_interval(0.2)
|
||||||
tween.tween_callback(_do_transition.bind(scene_path))
|
tween.tween_callback(_do_transition.bind(scene))
|
||||||
tween.tween_callback(func(): player.action_locked = false)
|
tween.tween_callback(func(): player.action_locked = false)
|
||||||
else:
|
else:
|
||||||
print("Scene not found: " + key)
|
print("Scene not found: " + key)
|
||||||
@ -69,13 +70,11 @@ func _update_player_position():
|
|||||||
player.global_position = ArchiveManager.archive.player_global_position
|
player.global_position = ArchiveManager.archive.player_global_position
|
||||||
player.set_facing_direction(ArchiveManager.archive.player_direction)
|
player.set_facing_direction(ArchiveManager.archive.player_direction)
|
||||||
|
|
||||||
func _do_transition(scene_path):
|
func _do_transition(scene: Node2D):
|
||||||
var new_ground = load(scene_path) as PackedScene
|
|
||||||
if ground:
|
if ground:
|
||||||
ground.queue_free()
|
ground.queue_free()
|
||||||
# 提前移除,防止命名冲突
|
# 提前移除,防止命名冲突
|
||||||
remove_child(ground)
|
remove_child(ground)
|
||||||
var scene = new_ground.instantiate()
|
|
||||||
ground = scene.get_child(0)
|
ground = scene.get_child(0)
|
||||||
scene.remove_child(ground)
|
scene.remove_child(ground)
|
||||||
scene.queue_free()
|
scene.queue_free()
|
||||||
|
@ -30,6 +30,7 @@ texture = null
|
|||||||
portal_name = "1"
|
portal_name = "1"
|
||||||
target_scene = "c02_s02"
|
target_scene = "c02_s02"
|
||||||
target_portal = "left"
|
target_portal = "left"
|
||||||
|
sound_effect = "channel"
|
||||||
|
|
||||||
[node name="Inspectable" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_g5fsn")]
|
[node name="Inspectable" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_g5fsn")]
|
||||||
position = Vector2(311, -7)
|
position = Vector2(311, -7)
|
||||||
|
@ -34,6 +34,7 @@ texture = null
|
|||||||
portal_name = "right"
|
portal_name = "right"
|
||||||
target_scene = "c02_s03"
|
target_scene = "c02_s03"
|
||||||
target_portal = "left"
|
target_portal = "left"
|
||||||
|
sound_effect = "channel"
|
||||||
|
|
||||||
[node name="鼠疫海报" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_nhtbp")]
|
[node name="鼠疫海报" parent="Ground/DeployLayer" index="3" instance=ExtResource("5_nhtbp")]
|
||||||
position = Vector2(277, -6)
|
position = Vector2(277, -6)
|
||||||
@ -45,12 +46,14 @@ texture = ExtResource("7_xsghn")
|
|||||||
flip_h = true
|
flip_h = true
|
||||||
|
|
||||||
[node name="StaticBody2D" type="StaticBody2D" parent="Ground/DeployLayer/纸人"]
|
[node name="StaticBody2D" type="StaticBody2D" parent="Ground/DeployLayer/纸人"]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/纸人/StaticBody2D"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground/DeployLayer/纸人/StaticBody2D"]
|
||||||
shape = SubResource("RectangleShape2D_0xrg2")
|
shape = SubResource("RectangleShape2D_0xrg2")
|
||||||
|
|
||||||
[node name="Ambush" parent="Ground/DeployLayer" index="5" instance=ExtResource("6_70vqn")]
|
[node name="Ambush" parent="Ground/DeployLayer" index="5" instance=ExtResource("6_70vqn")]
|
||||||
position = Vector2(377, 62)
|
position = Vector2(434, 60)
|
||||||
hook_cg = "c02_胖子说话"
|
hook_cg = "c02_胖子说话"
|
||||||
|
|
||||||
[node name="FGSprite2D" parent="Ground/ParallaxForeground/FGParallaxLayer" index="0"]
|
[node name="FGSprite2D" parent="Ground/ParallaxForeground/FGParallaxLayer" index="0"]
|
||||||
|
@ -24,6 +24,7 @@ scale = Vector2(1.02941, 1.06667)
|
|||||||
texture = null
|
texture = null
|
||||||
target_scene = "c02_s02"
|
target_scene = "c02_s02"
|
||||||
target_portal = "right"
|
target_portal = "right"
|
||||||
|
sound_effect = "channel"
|
||||||
|
|
||||||
[node name="Portal2" parent="Ground/DeployLayer" index="3" instance=ExtResource("4_gvtrn")]
|
[node name="Portal2" parent="Ground/DeployLayer" index="3" instance=ExtResource("4_gvtrn")]
|
||||||
position = Vector2(192, 8)
|
position = Vector2(192, 8)
|
||||||
|
Loading…
Reference in New Issue
Block a user