Add sound effects

This commit is contained in:
Marvin Dalheimer 2024-01-28 15:16:29 +01:00
parent 0abd197c18
commit ce13530dfa
Signed by: Rinma
GPG Key ID: 44CAD3A9F1679D8D
19 changed files with 577 additions and 163 deletions

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://0k6ujfaq7msw"
path="res://.godot/imported/buh_1.wav-e92be9823514555c18a1d85000eb7b5f.sample"
[deps]
source_file="res://audio/buh_1.wav"
dest_files=["res://.godot/imported/buh_1.wav-e92be9823514555c18a1d85000eb7b5f.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dwsveuqk75ael"
path="res://.godot/imported/buh_2.wav-3265de19d1ec12c358a8b7076a834489.sample"
[deps]
source_file="res://audio/buh_2.wav"
dest_files=["res://.godot/imported/buh_2.wav-3265de19d1ec12c358a8b7076a834489.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://fkwgly1jeqro"
path="res://.godot/imported/buh_3.wav-a51f4eb5ec7d0e39beb5b09148160404.sample"
[deps]
source_file="res://audio/buh_3.wav"
dest_files=["res://.godot/imported/buh_3.wav-a51f4eb5ec7d0e39beb5b09148160404.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://d1y3npku40ufd"
path="res://.godot/imported/buh_4.wav-051f93dfac6f5affe4111e95b81d366c.sample"
[deps]
source_file="res://audio/buh_4.wav"
dest_files=["res://.godot/imported/buh_4.wav-051f93dfac6f5affe4111e95b81d366c.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dxe2412gbht5x"
path="res://.godot/imported/cough_1.wav-64464c03d6559b420ee1e171b477560b.sample"
[deps]
source_file="res://audio/cough_1.wav"
dest_files=["res://.godot/imported/cough_1.wav-64464c03d6559b420ee1e171b477560b.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://04yaek8c54sk"
path="res://.godot/imported/cough_2.wav-479f12d101d6cd1066d489e83754c964.sample"
[deps]
source_file="res://audio/cough_2.wav"
dest_files=["res://.godot/imported/cough_2.wav-479f12d101d6cd1066d489e83754c964.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b0q3boyn1ivpk"
path="res://.godot/imported/cough_3.wav-9f6c98fa25daeb2d797c7b6d2d749f18.sample"
[deps]
source_file="res://audio/cough_3.wav"
dest_files=["res://.godot/imported/cough_3.wav-9f6c98fa25daeb2d797c7b6d2d749f18.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dirqt4slkf2qi"
path="res://.godot/imported/haha_1.wav-9427e5608055932c293e9ac065da8228.sample"
[deps]
source_file="res://audio/haha_1.wav"
dest_files=["res://.godot/imported/haha_1.wav-9427e5608055932c293e9ac065da8228.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bugi8raxy604q"
path="res://.godot/imported/haha_2.wav-ff41bdcb14ad06c10f2d09031e08b6f4.sample"
[deps]
source_file="res://audio/haha_2.wav"
dest_files=["res://.godot/imported/haha_2.wav-ff41bdcb14ad06c10f2d09031e08b6f4.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://do3t0b6nmai2x"
path="res://.godot/imported/haha_3.wav-21ca331f9acd246b9e4c523efb31e6c1.sample"
[deps]
source_file="res://audio/haha_3.wav"
dest_files=["res://.godot/imported/haha_3.wav-21ca331f9acd246b9e4c523efb31e6c1.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cnqxqkbvuttdm"
path="res://.godot/imported/haha_4.wav-42bc10d85a404b6f4a5abe9a7f7baf0b.sample"
[deps]
source_file="res://audio/haha_4.wav"
dest_files=["res://.godot/imported/haha_4.wav-42bc10d85a404b6f4a5abe9a7f7baf0b.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://uml0racw45mf"
path="res://.godot/imported/tim_blabla_1.wav-4f25400e13b50e69afd6ea760e82c8bb.sample"
[deps]
source_file="res://audio/tim_blabla_1.wav"
dest_files=["res://.godot/imported/tim_blabla_1.wav-4f25400e13b50e69afd6ea760e82c8bb.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b8vih1eklq0xs"
path="res://.godot/imported/tim_blabla_2.wav-bceb510a368831dc11e03222487328db.sample"
[deps]
source_file="res://audio/tim_blabla_2.wav"
dest_files=["res://.godot/imported/tim_blabla_2.wav-bceb510a368831dc11e03222487328db.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://d2ka2b15l2us"
path="res://.godot/imported/tim_blabla_3.wav-f7541f158e8afa9614fb099b23f606b9.sample"
[deps]
source_file="res://audio/tim_blabla_3.wav"
dest_files=["res://.godot/imported/tim_blabla_3.wav-f7541f158e8afa9614fb099b23f606b9.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://7nx6sepgu4w0"
path="res://.godot/imported/tim_blabla_4.wav-9d46330c2047d4f4fe7de99a4c161e6f.sample"
[deps]
source_file="res://audio/tim_blabla_4.wav"
dest_files=["res://.godot/imported/tim_blabla_4.wav-9d46330c2047d4f4fe7de99a4c161e6f.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View File

@ -11,101 +11,110 @@ var default_texture: Texture2D = load("res://sprites/tim_side.png")
var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg") var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg")
var last_joke: Joke var last_joke: Joke
var blabla_sounds = [
preload("res://audio/tim_blabla_1.wav"),
preload("res://audio/tim_blabla_2.wav"),
preload("res://audio/tim_blabla_3.wav"),
preload("res://audio/tim_blabla_4.wav")
]
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
Signals.hit_tim.connect(ouch) Signals.hit_tim.connect(ouch)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
if $AnimationPlayer.is_playing(): if $AnimationPlayer.is_playing():
return return
if Input.is_action_pressed("move_right"): if Input.is_action_pressed("move_right"):
tim_sprite.flip_h = true tim_sprite.flip_h = true
global_position += Vector2.RIGHT * delta * move_speed global_position += Vector2.RIGHT * delta * move_speed
if global_position.x > boundary.get_most_right_position(): if global_position.x > boundary.get_most_right_position():
global_position = Vector2(boundary.get_most_right_position(), global_position.y) global_position = Vector2(boundary.get_most_right_position(), global_position.y)
if Input.is_action_pressed("move_left"): if Input.is_action_pressed("move_left"):
tim_sprite.flip_h = false tim_sprite.flip_h = false
global_position += Vector2.LEFT * delta * move_speed global_position += Vector2.LEFT * delta * move_speed
if global_position.x < boundary.get_most_left_position(): if global_position.x < boundary.get_most_left_position():
global_position = Vector2(boundary.get_most_left_position(), global_position.y) global_position = Vector2(boundary.get_most_left_position(), global_position.y)
func _disable_buttons(): func _disable_buttons():
$"Joke Buttons".hide() $"Joke Buttons".hide()
$"Joke Buttons".process_mode = Node.PROCESS_MODE_DISABLED $"Joke Buttons".process_mode = Node.PROCESS_MODE_DISABLED
func _enable_buttons(): func _enable_buttons():
$"Joke Buttons".show() $"Joke Buttons".show()
$"Joke Buttons".process_mode = Node.PROCESS_MODE_INHERIT $"Joke Buttons".process_mode = Node.PROCESS_MODE_INHERIT
func _on_joke_button_button_pressed(joke: Joke): func _on_joke_button_button_pressed(joke: Joke):
last_joke = joke last_joke = joke
stamina -= joke.required_stamina stamina -= joke.required_stamina
_disable_buttons() _disable_buttons()
_start_joke_for_audience() _start_joke_for_audience()
$AnimationPlayer.play("talking") $AnimationPlayer.play("talking")
$Speaker.stream = blabla_sounds[randi() % blabla_sounds.size()]
$Speaker.play()
func _get_targeted_audience_members(target_all: bool): func _get_targeted_audience_members(target_all: bool):
if target_all: if target_all:
return _get_all_targeted_audience_members() return _get_all_targeted_audience_members()
return _get_targeted_audience_members_in_target_area() return _get_targeted_audience_members_in_target_area()
func _get_all_targeted_audience_members() -> Array[AudienceMember]: func _get_all_targeted_audience_members() -> Array[AudienceMember]:
var crowd = get_node("/root/IngameScene/Crowd") var crowd = get_node("/root/IngameScene/Crowd")
return crowd.audience return crowd.audience
func _get_targeted_audience_members_in_target_area() -> Array[AudienceMember]: func _get_targeted_audience_members_in_target_area() -> Array[AudienceMember]:
var arr: Array[AudienceMember] var arr: Array[AudienceMember]
for body in transmitter_area.get_overlapping_bodies(): for body in transmitter_area.get_overlapping_bodies():
var person = body.find_parent("Person") var person = body.find_parent("Person")
if not (person is AudienceMember): if not (person is AudienceMember):
continue continue
arr.append(person) arr.append(person)
return arr return arr
func _start_joke_for_audience(): func _start_joke_for_audience():
for person in _get_targeted_audience_members(true): for person in _get_targeted_audience_members(true):
person.on_joke_start() person.on_joke_start()
func _tell_joke_for_audience(joke: Joke, target_all: bool): func _tell_joke_for_audience(joke: Joke, target_all: bool):
for person in _get_targeted_audience_members(target_all): for person in _get_targeted_audience_members(target_all):
person.on_hear_joke(joke) person.on_hear_joke(joke)
func _finish_joke_for_audience(): func _finish_joke_for_audience():
for person in _get_targeted_audience_members(true): for person in _get_targeted_audience_members(true):
person.on_joke_finish() person.on_joke_finish()
func _on_stamina_empty(): func _on_stamina_empty():
get_node("../DisplayGUI").visible = false get_node("../DisplayGUI").visible = false
var fade = get_node("/root/IngameScene/UI/FadeOverlay") var fade = get_node("/root/IngameScene/UI/FadeOverlay")
fade.modulate.a = fade.minimum_opacity fade.modulate.a = fade.minimum_opacity
fade.visible = true fade.visible = true
get_node("/root/IngameScene/UI/Curtain").visible = true get_node("/root/IngameScene/UI/Curtain").visible = true
get_viewport().set_input_as_handled() get_viewport().set_input_as_handled()
get_tree().paused = true get_tree().paused = true
var score_overlay = get_node("/root/IngameScene/UI/ScoreOverlay") var score_overlay = get_node("/root/IngameScene/UI/ScoreOverlay")
score_overlay.get_node("VBoxContainer3/FinalScore").text = str(int(get_node("/root/IngameScene/Crowd").overall_mood)) score_overlay.get_node("VBoxContainer3/FinalScore").text = str(int(get_node("/root/IngameScene/Crowd").overall_mood))
score_overlay.grab_button_focus() score_overlay.grab_button_focus()
score_overlay.visible = true score_overlay.visible = true
pass pass
func ouch(): func ouch():
$Sprite2D.texture = ducking_texture $Sprite2D.texture = ducking_texture
_start_joke_for_audience() _start_joke_for_audience()
await get_tree().create_timer(1).timeout await get_tree().create_timer(1).timeout
$Sprite2D.texture = default_texture $Sprite2D.texture = default_texture
_tell_joke_for_audience(Joke.get_bottle_joke(), true) _tell_joke_for_audience(Joke.get_bottle_joke(), true)
_finish_joke_for_audience() _finish_joke_for_audience()
func _on_animation_player_animation_finished(anim_name): func _on_animation_player_animation_finished(anim_name):
_tell_joke_for_audience(last_joke, false) _tell_joke_for_audience(last_joke, false)
_finish_joke_for_audience() _finish_joke_for_audience()
if stamina <= 0: if stamina <= 0:
_on_stamina_empty() _on_stamina_empty()
else: else:
_enable_buttons() _enable_buttons()

View File

@ -16,145 +16,185 @@ var is_listening : bool = false
var last_joke_heard : Joke.JokeType = -1 var last_joke_heard : Joke.JokeType = -1
var known_faces : Array[String] = [ var known_faces : Array[String] = [
"res://scenes/faces/face_curly.tscn", "res://scenes/faces/face_curly.tscn",
"res://scenes/faces/face_jenny.tscn", "res://scenes/faces/face_jenny.tscn",
"res://scenes/faces/face_moritz.tscn", "res://scenes/faces/face_moritz.tscn",
"res://scenes/faces/face_ronald.tscn", "res://scenes/faces/face_ronald.tscn",
# Add more scenes as needed # Add more scenes as needed
] ]
var known_bodies = { var known_bodies = {
"blue" : [ "blue" : [
"res://scenes/bodies/body_blue_1.tscn", "res://scenes/bodies/body_blue_1.tscn",
"res://scenes/bodies/body_blue_2.tscn", "res://scenes/bodies/body_blue_2.tscn",
"res://scenes/bodies/body_blue_3.tscn", "res://scenes/bodies/body_blue_3.tscn",
# Add more scenes as needed # Add more scenes as needed
], ],
"green" : [ "green" : [
"res://scenes/bodies/body_green_1.tscn", "res://scenes/bodies/body_green_1.tscn",
"res://scenes/bodies/body_green_2.tscn", "res://scenes/bodies/body_green_2.tscn",
"res://scenes/bodies/body_green_3.tscn", "res://scenes/bodies/body_green_3.tscn",
# Add more scenes as needed # Add more scenes as needed
], ],
"red" : [ "red" : [
"res://scenes/bodies/body_red_1.tscn", "res://scenes/bodies/body_red_1.tscn",
"res://scenes/bodies/body_red_2.tscn", "res://scenes/bodies/body_red_2.tscn",
"res://scenes/bodies/body_red_3.tscn", "res://scenes/bodies/body_red_3.tscn",
# Add more scenes as needed # Add more scenes as needed
], ],
} }
var buh_sounds = [
preload("res://audio/buh_1.wav"),
preload("res://audio/buh_2.wav"),
preload("res://audio/buh_3.wav"),
preload("res://audio/buh_4.wav"),
]
var laugh_sounds = [
preload("res://audio/haha_1.wav"),
preload("res://audio/haha_2.wav"),
preload("res://audio/haha_3.wav"),
preload("res://audio/haha_4.wav"),
]
var cough_sounds = [
preload("res://audio/cough_1.wav"),
preload("res://audio/cough_2.wav"),
preload("res://audio/cough_3.wav"),
]
const laughter_duration : float = 2. # seconds const laughter_duration : float = 2. # seconds
const laughter_bobs : int = 4 const laughter_bobs : int = 4
var laughter_left : float = 0. var laughter_left : float = 0.
func _map_color_to_profile_data_index(color): func _map_color_to_profile_data_index(color):
match color: match color:
"green": "green":
return 0 return 0
"blue": "blue":
return 1 return 1
"red": "red":
return 2 return 2
return 0 return 0
static func get_random_color(): static func get_random_color():
var keys = ["blue", "green", "red"] var keys = ["blue", "green", "red"]
return keys[randi() % keys.size()] return keys[randi() % keys.size()]
func get_random_cough():
return cough_sounds[randi() % cough_sounds.size()]
func get_random_buh():
return buh_sounds[randi() % buh_sounds.size()]
func get_random_laugh():
return laugh_sounds[randi() % laugh_sounds.size()]
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
laughter_left = 0. laughter_left = 0.
mood = randf_range(profile.lashout_threshold, profile.happy_threshold) mood = randf_range(profile.lashout_threshold, profile.happy_threshold)
update_expression() update_expression()
var profile_index = _map_color_to_profile_data_index(color) var profile_index = _map_color_to_profile_data_index(color)
var profile_data = AudienceProfile.get_profile_data(profile_index) var profile_data = AudienceProfile.get_profile_data(profile_index)
profile.load_data(profile_data) profile.load_data(profile_data)
if body_shape == null: if body_shape == null:
set_random_body(color) set_random_body(color)
if face == null: if face == null:
set_random_face() set_random_face()
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
if laughter_left >= 0: if laughter_left >= 0:
laughter_left -= delta laughter_left -= delta
if not is_listening and mood > profile.happy_threshold * .5: if not is_listening and mood > profile.happy_threshold * .5:
mood -= profile.happiness_decay * delta mood -= profile.happiness_decay * delta
elif not is_listening and mood < profile.lashout_threshold * .9: elif not is_listening and mood < profile.lashout_threshold * .9:
mood += profile.lashout_decay * delta mood += profile.lashout_decay * delta
if mood < profile.lashout_threshold: if mood < profile.lashout_threshold:
throw_bottle() throw_bottle()
update_expression() update_expression()
func _input(event): func _input(event):
var just_pressed = event.is_pressed() and not event.is_echo() var just_pressed = event.is_pressed() and not event.is_echo()
if just_pressed and OS.is_debug_build(): if just_pressed and OS.is_debug_build():
if Input.is_key_pressed(KEY_SPACE): if Input.is_key_pressed(KEY_SPACE):
update_mood(1.) update_mood(1.)
elif Input.is_key_pressed(KEY_ENTER): elif Input.is_key_pressed(KEY_ENTER):
update_mood(-1.) update_mood(-1.)
func update_mood(change: float): func update_mood(change: float):
if mood > profile.happy_threshold and change > 0 and laughter_left <= 0: if mood > profile.happy_threshold and change > 0 and laughter_left <= 0:
laughter_left = laughter_duration laughter_left = laughter_duration
# bob head # bob head
var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs) var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs)
var bob_duration = laughter_duration / laughter_bobs / 2 var bob_duration = laughter_duration / laughter_bobs / 2
tween.tween_property(face, "position", Vector2.UP * 20, bob_duration).set_delay(randf_range(0, bob_duration))
tween.tween_property(face, "position", Vector2.ZERO, bob_duration)
mood += change $Speaker.stream = get_random_laugh()
$Speaker.play()
tween.tween_property(face, "position", Vector2.UP * 20, bob_duration).set_delay(randf_range(0, bob_duration))
tween.tween_property(face, "position", Vector2.ZERO, bob_duration)
mood += change
func update_expression(): func update_expression():
if laughter_left > 0: if laughter_left > 0:
expression = "laugh" expression = "laugh"
elif mood > profile.happy_threshold: elif mood > profile.happy_threshold:
expression = "happy" expression = "happy"
elif mood < profile.angry_threshold: elif mood < profile.angry_threshold:
expression = "angry" expression = "angry"
else: else:
expression = "neutral" expression = "neutral"
if randi() % 25000 == 1:
$Speaker.stream = get_random_cough()
$Speaker.play()
func set_random_body(for_color): func set_random_body(for_color):
if str(for_color) not in known_bodies: if str(for_color) not in known_bodies:
var keys = known_bodies.keys() var keys = known_bodies.keys()
for_color = keys[randi() % keys.size()] for_color = keys[randi() % keys.size()]
print(keys.size()) print(keys.size())
var body_path = known_bodies[for_color][randi() % known_bodies[for_color].size()] var body_path = known_bodies[for_color][randi() % known_bodies[for_color].size()]
var body_res = load(body_path) var body_res = load(body_path)
body_shape = body_res.instantiate() body_shape = body_res.instantiate()
body.add_child(body_shape) body.add_child(body_shape)
func set_random_face(): func set_random_face():
var face_res = load(known_faces[randi() % known_faces.size()]) var face_res = load(known_faces[randi() % known_faces.size()])
face = face_res.instantiate() face = face_res.instantiate()
head.add_child(face) head.add_child(face)
func on_joke_start(): func on_joke_start():
is_listening = true is_listening = true
func on_hear_joke(joke: Joke): func on_hear_joke(joke: Joke):
var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness
if joke.type == last_joke_heard: if joke.type == last_joke_heard:
mood_change = min(0, mood_change) mood_change = min(0, mood_change)
update_mood(mood_change) update_mood(mood_change)
last_joke_heard = joke.type last_joke_heard = joke.type
func on_joke_finish(): func on_joke_finish():
is_listening = false is_listening = false
func throw_bottle(): func throw_bottle():
mood += 2.0 mood += 2.0
var bottle_scene = preload("res://scenes/objects/bottle.tscn") $Speaker.stream = get_random_buh()
var bottle = bottle_scene.instantiate() $Speaker.play()
add_child(bottle); var bottle_scene = preload("res://scenes/objects/bottle.tscn")
var bottle = bottle_scene.instantiate()
add_child(bottle);

View File

@ -27,3 +27,6 @@ shape = SubResource("RectangleShape2D_5rd5b")
[node name="Profile" type="Node2D" parent="."] [node name="Profile" type="Node2D" parent="."]
script = ExtResource("2_bsodr") script = ExtResource("2_bsodr")
[node name="Speaker" type="AudioStreamPlayer2D" parent="."]
bus = &"Sound"

View File

@ -141,6 +141,8 @@ libraries = {
"": SubResource("AnimationLibrary_xvfym") "": SubResource("AnimationLibrary_xvfym")
} }
[node name="Speaker" type="AudioStreamPlayer2D" parent="Tim"]
[node name="Boundary" type="Node2D" parent="."] [node name="Boundary" type="Node2D" parent="."]
script = ExtResource("2_8p6ir") script = ExtResource("2_8p6ir")
width = 400.0 width = 400.0