Merge branch 'main' into audio
This commit is contained in:
commit
9831759095
|
@ -18,10 +18,12 @@ var blabla_sounds = [
|
||||||
preload("res://audio/tim_blabla_4.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():
|
||||||
|
@ -39,14 +41,17 @@ func _process(delta):
|
||||||
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
|
||||||
|
@ -56,15 +61,18 @@ func _on_joke_button_button_pressed(joke: Joke):
|
||||||
$Speaker.stream = blabla_sounds[randi() % blabla_sounds.size()]
|
$Speaker.stream = blabla_sounds[randi() % blabla_sounds.size()]
|
||||||
$Speaker.play()
|
$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():
|
||||||
|
@ -74,18 +82,22 @@ func _get_targeted_audience_members_in_target_area() -> Array[AudienceMember]:
|
||||||
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
|
||||||
|
|
||||||
|
@ -98,19 +110,30 @@ func _on_stamina_empty():
|
||||||
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
|
||||||
|
var bottle_joke = Joke.get_bottle_joke()
|
||||||
_start_joke_for_audience()
|
_start_joke_for_audience()
|
||||||
|
stamina -= bottle_joke.required_stamina
|
||||||
|
|
||||||
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(bottle_joke, true)
|
||||||
_finish_joke_for_audience()
|
_finish_joke_for_audience()
|
||||||
|
|
||||||
|
if stamina <= 0:
|
||||||
|
_on_stamina_empty()
|
||||||
|
|
||||||
|
|
||||||
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()
|
||||||
|
|
|
@ -1,6 +1,16 @@
|
||||||
class_name AudienceProfile
|
class_name AudienceProfile
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
|
const HAPPY_THRESHOLD: float = 2
|
||||||
|
const ANGRY_THRESHOLD: float = -1
|
||||||
|
const LASHOUT_THRESHOLD: float = -5
|
||||||
|
const HAPPINESS_DECAY: float = .01
|
||||||
|
const LASHOUT_DECAY: float = .01
|
||||||
|
|
||||||
|
const GOOD_REACTION: float = 1
|
||||||
|
const NEUTRAL_REACTION: float = .1
|
||||||
|
const BAD_REACTION: float = -1.2
|
||||||
|
const BOTTLE_REACTION: float = 3
|
||||||
|
|
||||||
class ProfileData:
|
class ProfileData:
|
||||||
var happy_threshold: float
|
var happy_threshold: float
|
||||||
|
@ -39,23 +49,12 @@ var joke_mood_mapping: Dictionary
|
||||||
|
|
||||||
static func get_profile_data(index) -> ProfileData:
|
static func get_profile_data(index) -> ProfileData:
|
||||||
var profiles = [
|
var profiles = [
|
||||||
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 1, 1: -0.25, 2: 0, 3: 2}),
|
ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: GOOD_REACTION, 1: BAD_REACTION, 2: NEUTRAL_REACTION, 3: BOTTLE_REACTION}),
|
||||||
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 0, 1: 1, 2: -0.25, 3: 2}),
|
ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: NEUTRAL_REACTION, 1: GOOD_REACTION, 2: BAD_REACTION, 3: BOTTLE_REACTION}),
|
||||||
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: -0.25, 1: 0, 2: 1, 3: 2}),
|
ProfileData.new(HAPPY_THRESHOLD, ANGRY_THRESHOLD, LASHOUT_THRESHOLD, HAPPINESS_DECAY, LASHOUT_DECAY, {0: BAD_REACTION, 1: NEUTRAL_REACTION, 2: GOOD_REACTION, 3: BOTTLE_REACTION}),
|
||||||
]
|
]
|
||||||
return profiles[index]
|
return profiles[index]
|
||||||
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready():
|
|
||||||
pass # Replace with function body.
|
|
||||||
|
|
||||||
|
|
||||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
||||||
func _process(_delta):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
func load_data(data: ProfileData):
|
func load_data(data: ProfileData):
|
||||||
happy_threshold = data.happy_threshold
|
happy_threshold = data.happy_threshold
|
||||||
angry_threshold = data.angry_threshold
|
angry_threshold = data.angry_threshold
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/crowd/crowd.gd" id="1_y7wyj"]
|
[ext_resource type="Script" path="res://scenes/crowd/crowd.gd" id="1_y7wyj"]
|
||||||
[ext_resource type="Texture2D" uid="uid://b6p145ne8x013" path="res://sprites/room/table.svg" id="2_bax5s"]
|
[ext_resource type="Texture2D" uid="uid://b6p145ne8x013" path="res://sprites/room/table.svg" id="2_bax5s"]
|
||||||
[ext_resource type="PackedScene" path="res://sprites/room/chair.tscn" id="3_y4hpm"]
|
[ext_resource type="PackedScene" uid="uid://bbehbuw5lvfkr" path="res://sprites/room/chair.tscn" id="3_y4hpm"]
|
||||||
|
|
||||||
[node name="Crowd" type="Node2D"]
|
[node name="Crowd" type="Node2D"]
|
||||||
position = Vector2(240, 232)
|
position = Vector2(240, 232)
|
||||||
|
|
|
@ -112,12 +112,11 @@ 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 * .9:
|
||||||
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()
|
||||||
|
|
||||||
|
@ -132,11 +131,13 @@ func _input(event):
|
||||||
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 laughter_left <= 0 and change > 0 and (mood + change) > profile.happy_threshold :
|
||||||
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)
|
||||||
|
|
||||||
$Speaker.stream = get_random_laugh()
|
$Speaker.stream = get_random_laugh()
|
||||||
$Speaker.play()
|
$Speaker.play()
|
||||||
|
@ -180,8 +181,8 @@ func on_joke_start():
|
||||||
|
|
||||||
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 and mood_change > 0:
|
||||||
mood_change = min(0, mood_change)
|
mood_change *= .5
|
||||||
update_mood(mood_change)
|
update_mood(mood_change)
|
||||||
last_joke_heard = joke.type
|
last_joke_heard = joke.type
|
||||||
|
|
||||||
|
@ -189,7 +190,7 @@ func on_joke_finish():
|
||||||
is_listening = false
|
is_listening = false
|
||||||
|
|
||||||
func throw_bottle():
|
func throw_bottle():
|
||||||
mood += 2.0
|
mood = profile.lashout_threshold * 0.99
|
||||||
|
|
||||||
$Speaker.stream = get_random_buh()
|
$Speaker.stream = get_random_buh()
|
||||||
$Speaker.play()
|
$Speaker.play()
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 792 B |
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://c37ydueny6n1f"
|
|
||||||
path="res://.godot/imported/table.png-4bc92ae90425ddea852f77e75ef69549.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://scenes/crowd/table.png"
|
|
||||||
dest_files=["res://.godot/imported/table.png-4bc92ae90425ddea852f77e75ef69549.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -10,6 +10,12 @@ var is_hidding: bool
|
||||||
# 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():
|
||||||
tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position
|
tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position
|
||||||
|
tim_global_position += _random_inside_unit_circle() * 23
|
||||||
|
rotation_degrees += randf() * 360
|
||||||
|
|
||||||
|
func _random_inside_unit_circle() -> Vector2:
|
||||||
|
var theta : float = randf() * 2 * PI
|
||||||
|
return Vector2(cos(theta), sin(theta)) * sqrt(randf())
|
||||||
|
|
||||||
# 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):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://c5f5v1wtottyp"]
|
[gd_scene load_steps=4 format=3 uid="uid://c5f5v1wtottyp"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scenes/objects/bottle.gd" id="1_87ktq"]
|
[ext_resource type="Script" path="res://scenes/objects/bottle.gd" id="1_87ktq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cow4dd0hlxrgr" path="res://sprites/room/bottle.svg" id="1_uea7l"]
|
[ext_resource type="Texture2D" uid="uid://bavsg3hu7pccy" path="res://sprites/room/bottle.svg" id="1_uea7l"]
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_p8qcj"]
|
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_p8qcj"]
|
||||||
radius = 22.4893
|
radius = 22.4893
|
||||||
|
|
|
@ -19,7 +19,7 @@ var required_stamina: int
|
||||||
var effectiveness: float
|
var effectiveness: float
|
||||||
|
|
||||||
static func get_bottle_joke():
|
static func get_bottle_joke():
|
||||||
return Joke.new(JokeType.Bottle, 0, 1)
|
return Joke.new(JokeType.Bottle, 15, 1)
|
||||||
|
|
||||||
static func get_random_joke(type):
|
static func get_random_joke(type):
|
||||||
var stamina = STAMINA_CATEGORIES[randi_range(0, STAMINA_CATEGORIES.size() - 1)]
|
var stamina = STAMINA_CATEGORIES[randi_range(0, STAMINA_CATEGORIES.size() - 1)]
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue