Add sound effects
This commit is contained in:
parent
0abd197c18
commit
ce13530dfa
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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 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.
|
||||
func _ready():
|
||||
Signals.hit_tim.connect(ouch)
|
||||
Signals.hit_tim.connect(ouch)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if $AnimationPlayer.is_playing():
|
||||
return
|
||||
if $AnimationPlayer.is_playing():
|
||||
return
|
||||
|
||||
if Input.is_action_pressed("move_right"):
|
||||
tim_sprite.flip_h = true
|
||||
global_position += Vector2.RIGHT * delta * move_speed
|
||||
if global_position.x > boundary.get_most_right_position():
|
||||
global_position = Vector2(boundary.get_most_right_position(), global_position.y)
|
||||
if Input.is_action_pressed("move_right"):
|
||||
tim_sprite.flip_h = true
|
||||
global_position += Vector2.RIGHT * delta * move_speed
|
||||
if global_position.x > boundary.get_most_right_position():
|
||||
global_position = Vector2(boundary.get_most_right_position(), global_position.y)
|
||||
|
||||
if Input.is_action_pressed("move_left"):
|
||||
tim_sprite.flip_h = false
|
||||
global_position += Vector2.LEFT * delta * move_speed
|
||||
if global_position.x < boundary.get_most_left_position():
|
||||
global_position = Vector2(boundary.get_most_left_position(), global_position.y)
|
||||
if Input.is_action_pressed("move_left"):
|
||||
tim_sprite.flip_h = false
|
||||
global_position += Vector2.LEFT * delta * move_speed
|
||||
if global_position.x < boundary.get_most_left_position():
|
||||
global_position = Vector2(boundary.get_most_left_position(), global_position.y)
|
||||
|
||||
func _disable_buttons():
|
||||
$"Joke Buttons".hide()
|
||||
$"Joke Buttons".process_mode = Node.PROCESS_MODE_DISABLED
|
||||
$"Joke Buttons".hide()
|
||||
$"Joke Buttons".process_mode = Node.PROCESS_MODE_DISABLED
|
||||
|
||||
func _enable_buttons():
|
||||
$"Joke Buttons".show()
|
||||
$"Joke Buttons".process_mode = Node.PROCESS_MODE_INHERIT
|
||||
$"Joke Buttons".show()
|
||||
$"Joke Buttons".process_mode = Node.PROCESS_MODE_INHERIT
|
||||
|
||||
func _on_joke_button_button_pressed(joke: Joke):
|
||||
last_joke = joke
|
||||
stamina -= joke.required_stamina
|
||||
_disable_buttons()
|
||||
_start_joke_for_audience()
|
||||
$AnimationPlayer.play("talking")
|
||||
last_joke = joke
|
||||
stamina -= joke.required_stamina
|
||||
_disable_buttons()
|
||||
_start_joke_for_audience()
|
||||
$AnimationPlayer.play("talking")
|
||||
$Speaker.stream = blabla_sounds[randi() % blabla_sounds.size()]
|
||||
$Speaker.play()
|
||||
|
||||
func _get_targeted_audience_members(target_all: bool):
|
||||
if target_all:
|
||||
return _get_all_targeted_audience_members()
|
||||
return _get_targeted_audience_members_in_target_area()
|
||||
if target_all:
|
||||
return _get_all_targeted_audience_members()
|
||||
return _get_targeted_audience_members_in_target_area()
|
||||
|
||||
func _get_all_targeted_audience_members() -> Array[AudienceMember]:
|
||||
var crowd = get_node("/root/IngameScene/Crowd")
|
||||
return crowd.audience
|
||||
var crowd = get_node("/root/IngameScene/Crowd")
|
||||
return crowd.audience
|
||||
|
||||
func _get_targeted_audience_members_in_target_area() -> Array[AudienceMember]:
|
||||
var arr: Array[AudienceMember]
|
||||
for body in transmitter_area.get_overlapping_bodies():
|
||||
var person = body.find_parent("Person")
|
||||
if not (person is AudienceMember):
|
||||
continue
|
||||
arr.append(person)
|
||||
return arr
|
||||
var arr: Array[AudienceMember]
|
||||
for body in transmitter_area.get_overlapping_bodies():
|
||||
var person = body.find_parent("Person")
|
||||
if not (person is AudienceMember):
|
||||
continue
|
||||
arr.append(person)
|
||||
return arr
|
||||
|
||||
func _start_joke_for_audience():
|
||||
for person in _get_targeted_audience_members(true):
|
||||
person.on_joke_start()
|
||||
for person in _get_targeted_audience_members(true):
|
||||
person.on_joke_start()
|
||||
|
||||
func _tell_joke_for_audience(joke: Joke, target_all: bool):
|
||||
for person in _get_targeted_audience_members(target_all):
|
||||
person.on_hear_joke(joke)
|
||||
for person in _get_targeted_audience_members(target_all):
|
||||
person.on_hear_joke(joke)
|
||||
|
||||
func _finish_joke_for_audience():
|
||||
for person in _get_targeted_audience_members(true):
|
||||
person.on_joke_finish()
|
||||
for person in _get_targeted_audience_members(true):
|
||||
person.on_joke_finish()
|
||||
|
||||
func _on_stamina_empty():
|
||||
get_node("../DisplayGUI").visible = false
|
||||
|
||||
var fade = get_node("/root/IngameScene/UI/FadeOverlay")
|
||||
fade.modulate.a = fade.minimum_opacity
|
||||
fade.visible = true
|
||||
get_node("/root/IngameScene/UI/Curtain").visible = true
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
get_tree().paused = true
|
||||
|
||||
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.grab_button_focus()
|
||||
score_overlay.visible = true
|
||||
pass
|
||||
get_node("../DisplayGUI").visible = false
|
||||
|
||||
var fade = get_node("/root/IngameScene/UI/FadeOverlay")
|
||||
fade.modulate.a = fade.minimum_opacity
|
||||
fade.visible = true
|
||||
get_node("/root/IngameScene/UI/Curtain").visible = true
|
||||
|
||||
get_viewport().set_input_as_handled()
|
||||
get_tree().paused = true
|
||||
|
||||
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.grab_button_focus()
|
||||
score_overlay.visible = true
|
||||
pass
|
||||
|
||||
func ouch():
|
||||
$Sprite2D.texture = ducking_texture
|
||||
_start_joke_for_audience()
|
||||
await get_tree().create_timer(1).timeout
|
||||
$Sprite2D.texture = default_texture
|
||||
_tell_joke_for_audience(Joke.get_bottle_joke(), true)
|
||||
_finish_joke_for_audience()
|
||||
$Sprite2D.texture = ducking_texture
|
||||
_start_joke_for_audience()
|
||||
await get_tree().create_timer(1).timeout
|
||||
$Sprite2D.texture = default_texture
|
||||
_tell_joke_for_audience(Joke.get_bottle_joke(), true)
|
||||
_finish_joke_for_audience()
|
||||
|
||||
func _on_animation_player_animation_finished(anim_name):
|
||||
_tell_joke_for_audience(last_joke, false)
|
||||
_finish_joke_for_audience()
|
||||
if stamina <= 0:
|
||||
_on_stamina_empty()
|
||||
else:
|
||||
_enable_buttons()
|
||||
_tell_joke_for_audience(last_joke, false)
|
||||
_finish_joke_for_audience()
|
||||
if stamina <= 0:
|
||||
_on_stamina_empty()
|
||||
else:
|
||||
_enable_buttons()
|
||||
|
|
|
@ -16,145 +16,185 @@ var is_listening : bool = false
|
|||
var last_joke_heard : Joke.JokeType = -1
|
||||
|
||||
var known_faces : Array[String] = [
|
||||
"res://scenes/faces/face_curly.tscn",
|
||||
"res://scenes/faces/face_jenny.tscn",
|
||||
"res://scenes/faces/face_moritz.tscn",
|
||||
"res://scenes/faces/face_ronald.tscn",
|
||||
# Add more scenes as needed
|
||||
"res://scenes/faces/face_curly.tscn",
|
||||
"res://scenes/faces/face_jenny.tscn",
|
||||
"res://scenes/faces/face_moritz.tscn",
|
||||
"res://scenes/faces/face_ronald.tscn",
|
||||
# Add more scenes as needed
|
||||
]
|
||||
|
||||
var known_bodies = {
|
||||
"blue" : [
|
||||
"res://scenes/bodies/body_blue_1.tscn",
|
||||
"res://scenes/bodies/body_blue_2.tscn",
|
||||
"res://scenes/bodies/body_blue_3.tscn",
|
||||
# Add more scenes as needed
|
||||
],
|
||||
"green" : [
|
||||
"res://scenes/bodies/body_green_1.tscn",
|
||||
"res://scenes/bodies/body_green_2.tscn",
|
||||
"res://scenes/bodies/body_green_3.tscn",
|
||||
# Add more scenes as needed
|
||||
],
|
||||
"red" : [
|
||||
"res://scenes/bodies/body_red_1.tscn",
|
||||
"res://scenes/bodies/body_red_2.tscn",
|
||||
"res://scenes/bodies/body_red_3.tscn",
|
||||
# Add more scenes as needed
|
||||
],
|
||||
"blue" : [
|
||||
"res://scenes/bodies/body_blue_1.tscn",
|
||||
"res://scenes/bodies/body_blue_2.tscn",
|
||||
"res://scenes/bodies/body_blue_3.tscn",
|
||||
# Add more scenes as needed
|
||||
],
|
||||
"green" : [
|
||||
"res://scenes/bodies/body_green_1.tscn",
|
||||
"res://scenes/bodies/body_green_2.tscn",
|
||||
"res://scenes/bodies/body_green_3.tscn",
|
||||
# Add more scenes as needed
|
||||
],
|
||||
"red" : [
|
||||
"res://scenes/bodies/body_red_1.tscn",
|
||||
"res://scenes/bodies/body_red_2.tscn",
|
||||
"res://scenes/bodies/body_red_3.tscn",
|
||||
# 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_bobs : int = 4
|
||||
var laughter_left : float = 0.
|
||||
|
||||
func _map_color_to_profile_data_index(color):
|
||||
match color:
|
||||
"green":
|
||||
return 0
|
||||
"blue":
|
||||
return 1
|
||||
"red":
|
||||
return 2
|
||||
return 0
|
||||
match color:
|
||||
"green":
|
||||
return 0
|
||||
"blue":
|
||||
return 1
|
||||
"red":
|
||||
return 2
|
||||
return 0
|
||||
|
||||
static func get_random_color():
|
||||
var keys = ["blue", "green", "red"]
|
||||
return keys[randi() % keys.size()]
|
||||
var keys = ["blue", "green", "red"]
|
||||
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.
|
||||
func _ready():
|
||||
laughter_left = 0.
|
||||
mood = randf_range(profile.lashout_threshold, profile.happy_threshold)
|
||||
update_expression()
|
||||
laughter_left = 0.
|
||||
mood = randf_range(profile.lashout_threshold, profile.happy_threshold)
|
||||
update_expression()
|
||||
|
||||
var profile_index = _map_color_to_profile_data_index(color)
|
||||
var profile_data = AudienceProfile.get_profile_data(profile_index)
|
||||
profile.load_data(profile_data)
|
||||
var profile_index = _map_color_to_profile_data_index(color)
|
||||
var profile_data = AudienceProfile.get_profile_data(profile_index)
|
||||
profile.load_data(profile_data)
|
||||
|
||||
if body_shape == null:
|
||||
set_random_body(color)
|
||||
if body_shape == null:
|
||||
set_random_body(color)
|
||||
|
||||
if face == null:
|
||||
set_random_face()
|
||||
if face == null:
|
||||
set_random_face()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if laughter_left >= 0:
|
||||
laughter_left -= delta
|
||||
if laughter_left >= 0:
|
||||
laughter_left -= delta
|
||||
|
||||
if not is_listening and mood > profile.happy_threshold * .5:
|
||||
mood -= profile.happiness_decay * delta
|
||||
elif not is_listening and mood < profile.lashout_threshold * .9:
|
||||
mood += profile.lashout_decay * delta
|
||||
if not is_listening and mood > profile.happy_threshold * .5:
|
||||
mood -= profile.happiness_decay * delta
|
||||
elif not is_listening and mood < profile.lashout_threshold * .9:
|
||||
mood += profile.lashout_decay * delta
|
||||
|
||||
|
||||
if mood < profile.lashout_threshold:
|
||||
throw_bottle()
|
||||
if mood < profile.lashout_threshold:
|
||||
throw_bottle()
|
||||
|
||||
update_expression()
|
||||
update_expression()
|
||||
|
||||
func _input(event):
|
||||
var just_pressed = event.is_pressed() and not event.is_echo()
|
||||
if just_pressed and OS.is_debug_build():
|
||||
if Input.is_key_pressed(KEY_SPACE):
|
||||
update_mood(1.)
|
||||
elif Input.is_key_pressed(KEY_ENTER):
|
||||
update_mood(-1.)
|
||||
var just_pressed = event.is_pressed() and not event.is_echo()
|
||||
if just_pressed and OS.is_debug_build():
|
||||
if Input.is_key_pressed(KEY_SPACE):
|
||||
update_mood(1.)
|
||||
elif Input.is_key_pressed(KEY_ENTER):
|
||||
update_mood(-1.)
|
||||
|
||||
func update_mood(change: float):
|
||||
if mood > profile.happy_threshold and change > 0 and laughter_left <= 0:
|
||||
laughter_left = laughter_duration
|
||||
# bob head
|
||||
var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs)
|
||||
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)
|
||||
if mood > profile.happy_threshold and change > 0 and laughter_left <= 0:
|
||||
laughter_left = laughter_duration
|
||||
# bob head
|
||||
var tween = get_tree().create_tween().bind_node(self).set_loops(laughter_bobs)
|
||||
var bob_duration = laughter_duration / laughter_bobs / 2
|
||||
|
||||
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():
|
||||
if laughter_left > 0:
|
||||
expression = "laugh"
|
||||
elif mood > profile.happy_threshold:
|
||||
expression = "happy"
|
||||
elif mood < profile.angry_threshold:
|
||||
expression = "angry"
|
||||
else:
|
||||
expression = "neutral"
|
||||
if laughter_left > 0:
|
||||
expression = "laugh"
|
||||
elif mood > profile.happy_threshold:
|
||||
expression = "happy"
|
||||
elif mood < profile.angry_threshold:
|
||||
expression = "angry"
|
||||
else:
|
||||
expression = "neutral"
|
||||
|
||||
if randi() % 25000 == 1:
|
||||
$Speaker.stream = get_random_cough()
|
||||
$Speaker.play()
|
||||
|
||||
func set_random_body(for_color):
|
||||
if str(for_color) not in known_bodies:
|
||||
var keys = known_bodies.keys()
|
||||
for_color = keys[randi() % keys.size()]
|
||||
print(keys.size())
|
||||
var body_path = known_bodies[for_color][randi() % known_bodies[for_color].size()]
|
||||
var body_res = load(body_path)
|
||||
body_shape = body_res.instantiate()
|
||||
body.add_child(body_shape)
|
||||
if str(for_color) not in known_bodies:
|
||||
var keys = known_bodies.keys()
|
||||
for_color = keys[randi() % keys.size()]
|
||||
print(keys.size())
|
||||
var body_path = known_bodies[for_color][randi() % known_bodies[for_color].size()]
|
||||
var body_res = load(body_path)
|
||||
body_shape = body_res.instantiate()
|
||||
body.add_child(body_shape)
|
||||
|
||||
func set_random_face():
|
||||
var face_res = load(known_faces[randi() % known_faces.size()])
|
||||
face = face_res.instantiate()
|
||||
head.add_child(face)
|
||||
var face_res = load(known_faces[randi() % known_faces.size()])
|
||||
face = face_res.instantiate()
|
||||
head.add_child(face)
|
||||
|
||||
func on_joke_start():
|
||||
is_listening = true
|
||||
is_listening = true
|
||||
|
||||
func on_hear_joke(joke: Joke):
|
||||
var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness
|
||||
if joke.type == last_joke_heard:
|
||||
mood_change = min(0, mood_change)
|
||||
update_mood(mood_change)
|
||||
last_joke_heard = joke.type
|
||||
var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness
|
||||
if joke.type == last_joke_heard:
|
||||
mood_change = min(0, mood_change)
|
||||
update_mood(mood_change)
|
||||
last_joke_heard = joke.type
|
||||
|
||||
func on_joke_finish():
|
||||
is_listening = false
|
||||
is_listening = false
|
||||
|
||||
func throw_bottle():
|
||||
mood += 2.0
|
||||
mood += 2.0
|
||||
|
||||
var bottle_scene = preload("res://scenes/objects/bottle.tscn")
|
||||
var bottle = bottle_scene.instantiate()
|
||||
$Speaker.stream = get_random_buh()
|
||||
$Speaker.play()
|
||||
|
||||
add_child(bottle);
|
||||
var bottle_scene = preload("res://scenes/objects/bottle.tscn")
|
||||
var bottle = bottle_scene.instantiate()
|
||||
|
||||
add_child(bottle);
|
||||
|
|
|
@ -27,3 +27,6 @@ shape = SubResource("RectangleShape2D_5rd5b")
|
|||
|
||||
[node name="Profile" type="Node2D" parent="."]
|
||||
script = ExtResource("2_bsodr")
|
||||
|
||||
[node name="Speaker" type="AudioStreamPlayer2D" parent="."]
|
||||
bus = &"Sound"
|
||||
|
|
|
@ -141,6 +141,8 @@ libraries = {
|
|||
"": SubResource("AnimationLibrary_xvfym")
|
||||
}
|
||||
|
||||
[node name="Speaker" type="AudioStreamPlayer2D" parent="Tim"]
|
||||
|
||||
[node name="Boundary" type="Node2D" parent="."]
|
||||
script = ExtResource("2_8p6ir")
|
||||
width = 400.0
|
||||
|
|
Loading…
Reference in New Issue