31 lines
728 B
GDScript
31 lines
728 B
GDScript
extends Node2D
|
|
|
|
@export var scene_config: SceneConfig
|
|
|
|
@onready var foreground = %ParallaxForeground as ParallaxBackground
|
|
|
|
var footstep_audio = RandomAudioStreamPlayer.new()
|
|
|
|
|
|
func _ready() -> void:
|
|
foreground.layer = GlobalConfig.CANVAS_LAYER_FG
|
|
add_child(footstep_audio)
|
|
reload()
|
|
|
|
|
|
func reload():
|
|
if not scene_config:
|
|
footstep_audio.audio_collections.clear()
|
|
return
|
|
var type = scene_config.footstep_type
|
|
if type == "none":
|
|
return
|
|
footstep_audio.audio_collections.clear()
|
|
var audio = SceneConfig.FOOTSTEP_AUDIO[type] as AudioStreamCollection
|
|
footstep_audio.audio_collections.append(audio)
|
|
|
|
|
|
func play_footstep_sound() -> void:
|
|
if not footstep_audio.audio_collections.is_empty():
|
|
footstep_audio.play_random()
|