Wire elevator panel sfx and randomized chase music
Play SfxOpen on floor start, ding each blocked pulse, and close on the countdown into the next floor - start a randomized chase track per pulse (avoiding immediate repeats) and fade it out via tween on block or doors closing - Delay the auto-close after the final survivor by 0.25s so the ding doesn't collide with the close sound!
This commit is contained in:
parent
3bf436b7d2
commit
c2f2201c98
1 changed files with 39 additions and 3 deletions
|
|
@ -19,6 +19,14 @@ var points_per_person := 100 # base + bonus per person above threshold
|
||||||
|
|
||||||
var people_in_elevator := 0
|
var people_in_elevator := 0
|
||||||
|
|
||||||
|
const CHASE_SHORT_1 := preload("res://audio/Shortchase1.wav")
|
||||||
|
const CHASE_SHORT_2 := preload("res://audio/Shortchase2.wav")
|
||||||
|
const CHASE_MID := preload("res://audio/Midchase1.wav")
|
||||||
|
const CHASE_LONG := preload("res://audio/Chase1.wav")
|
||||||
|
const CHASE_TRACKS := [CHASE_SHORT_1, CHASE_SHORT_2, CHASE_MID, CHASE_LONG]
|
||||||
|
var _last_chase: AudioStream = null
|
||||||
|
var _chase_tween: Tween = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var button = $PanelMargin/PanelColumn/CloseButton
|
var button = $PanelMargin/PanelColumn/CloseButton
|
||||||
button.text = "BLOCK"
|
button.text = "BLOCK"
|
||||||
|
|
@ -38,6 +46,7 @@ func _unhandled_input(event):
|
||||||
# --- Floor lifecycle ---
|
# --- Floor lifecycle ---
|
||||||
|
|
||||||
func _start_floor():
|
func _start_floor():
|
||||||
|
$SfxOpen.play()
|
||||||
doors_closing_flag = false
|
doors_closing_flag = false
|
||||||
people_in_elevator = 0
|
people_in_elevator = 0
|
||||||
|
|
||||||
|
|
@ -51,6 +60,7 @@ func _start_floor():
|
||||||
var screen = $PanelMargin/PanelColumn/Screen
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
screen.start()
|
screen.start()
|
||||||
screen.launch_pulse() # first survivor arrives
|
screen.launch_pulse() # first survivor arrives
|
||||||
|
_start_chase()
|
||||||
|
|
||||||
# --- Input ---
|
# --- Input ---
|
||||||
|
|
||||||
|
|
@ -62,14 +72,17 @@ func _on_block_pressed():
|
||||||
# --- Pulse callbacks ---
|
# --- Pulse callbacks ---
|
||||||
|
|
||||||
func _on_pulse_blocked():
|
func _on_pulse_blocked():
|
||||||
|
_stop_chase()
|
||||||
# This survivor made it in
|
# This survivor made it in
|
||||||
survivors_remaining -= 1
|
survivors_remaining -= 1
|
||||||
people_in_elevator += 1
|
people_in_elevator += 1
|
||||||
|
$SfxDing.play()
|
||||||
EventBus.people_changed.emit(people_in_elevator, threshold)
|
EventBus.people_changed.emit(people_in_elevator, threshold)
|
||||||
|
|
||||||
if survivors_remaining <= 0:
|
if survivors_remaining <= 0:
|
||||||
# Everyone's in, close doors (auto-success)
|
# Everyone's in, close doors (auto-success). Brief delay so the
|
||||||
_on_doors_closing()
|
# last ding doesn't collide with the close sound.
|
||||||
|
get_tree().create_timer(0.25).timeout.connect(_on_doors_closing, CONNECT_ONE_SHOT)
|
||||||
return
|
return
|
||||||
|
|
||||||
# More survivors approaching: launch next pulse after gap
|
# More survivors approaching: launch next pulse after gap
|
||||||
|
|
@ -78,7 +91,8 @@ func _on_pulse_blocked():
|
||||||
get_tree().create_timer(gap).timeout.connect(
|
get_tree().create_timer(gap).timeout.connect(
|
||||||
func():
|
func():
|
||||||
if not doors_closing_flag:
|
if not doors_closing_flag:
|
||||||
screen.launch_pulse(),
|
screen.launch_pulse()
|
||||||
|
_start_chase(),
|
||||||
CONNECT_ONE_SHOT
|
CONNECT_ONE_SHOT
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -87,6 +101,8 @@ func _on_doors_closing():
|
||||||
return
|
return
|
||||||
doors_closing_flag = true
|
doors_closing_flag = true
|
||||||
|
|
||||||
|
_stop_chase()
|
||||||
|
|
||||||
var screen = $PanelMargin/PanelColumn/Screen
|
var screen = $PanelMargin/PanelColumn/Screen
|
||||||
|
|
||||||
# Lose: not enough people
|
# Lose: not enough people
|
||||||
|
|
@ -114,9 +130,29 @@ func _on_doors_closing():
|
||||||
return
|
return
|
||||||
|
|
||||||
# Next floor after countdown
|
# Next floor after countdown
|
||||||
|
$SfxClose.play()
|
||||||
screen.show_countdown()
|
screen.show_countdown()
|
||||||
screen.shrink_block_zone()
|
screen.shrink_block_zone()
|
||||||
|
|
||||||
var tween = create_tween()
|
var tween = create_tween()
|
||||||
tween.tween_interval(2.0)
|
tween.tween_interval(2.0)
|
||||||
tween.tween_callback(_start_floor)
|
tween.tween_callback(_start_floor)
|
||||||
|
|
||||||
|
func _start_chase():
|
||||||
|
if _chase_tween and _chase_tween.is_valid():
|
||||||
|
_chase_tween.kill()
|
||||||
|
|
||||||
|
var candidates: Array = CHASE_TRACKS.filter(func(s): return s != _last_chase)
|
||||||
|
var stream: AudioStream = candidates[randi() % candidates.size()]
|
||||||
|
_last_chase = stream
|
||||||
|
|
||||||
|
$SfxChase.stream = stream
|
||||||
|
$SfxChase.volume_db = 0.0
|
||||||
|
$SfxChase.play()
|
||||||
|
|
||||||
|
func _stop_chase():
|
||||||
|
if _chase_tween and _chase_tween.is_valid():
|
||||||
|
_chase_tween.kill()
|
||||||
|
_chase_tween = create_tween()
|
||||||
|
_chase_tween.tween_property($SfxChase, "volume_db", -80.0, 0.3)
|
||||||
|
_chase_tween.tween_callback($SfxChase.stop)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue