Merge branch 'main' into audio
This commit is contained in:
commit
9831759095
|
@ -12,109 +12,132 @@ 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")
|
||||
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")
|
||||
$Speaker.stream = blabla_sounds[randi() % blabla_sounds.size()]
|
||||
$Speaker.play()
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
var bottle_joke = Joke.get_bottle_joke()
|
||||
_start_joke_for_audience()
|
||||
stamina -= bottle_joke.required_stamina
|
||||
|
||||
await get_tree().create_timer(1).timeout
|
||||
|
||||
$Sprite2D.texture = default_texture
|
||||
_tell_joke_for_audience(bottle_joke, true)
|
||||
_finish_joke_for_audience()
|
||||
|
||||
if stamina <= 0:
|
||||
_on_stamina_empty()
|
||||
|
||||
|
||||
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()
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
class_name AudienceProfile
|
||||
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:
|
||||
var happy_threshold: float
|
||||
|
@ -39,23 +49,12 @@ var joke_mood_mapping: Dictionary
|
|||
|
||||
static func get_profile_data(index) -> ProfileData:
|
||||
var profiles = [
|
||||
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 1, 1: -0.25, 2: 0, 3: 2}),
|
||||
ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 0, 1: 1, 2: -0.25, 3: 2}),
|
||||
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: GOOD_REACTION, 1: BAD_REACTION, 2: NEUTRAL_REACTION, 3: BOTTLE_REACTION}),
|
||||
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(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]
|
||||
|
||||
|
||||
# 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):
|
||||
happy_threshold = data.happy_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="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"]
|
||||
position = Vector2(240, 232)
|
||||
|
|
|
@ -112,11 +112,10 @@ func _process(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 * .9:
|
||||
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()
|
||||
|
@ -132,11 +131,13 @@ func _input(event):
|
|||
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
|
||||
if laughter_left <= 0 and change > 0 and (mood + change) > profile.happy_threshold :
|
||||
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)
|
||||
|
||||
$Speaker.stream = get_random_laugh()
|
||||
$Speaker.play()
|
||||
|
@ -179,17 +180,17 @@ func on_joke_start():
|
|||
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 and mood_change > 0:
|
||||
mood_change *= .5
|
||||
update_mood(mood_change)
|
||||
last_joke_heard = joke.type
|
||||
|
||||
func on_joke_finish():
|
||||
is_listening = false
|
||||
|
||||
func throw_bottle():
|
||||
mood += 2.0
|
||||
mood = profile.lashout_threshold * 0.99
|
||||
|
||||
$Speaker.stream = get_random_buh()
|
||||
$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.
|
||||
func _ready():
|
||||
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.
|
||||
func _process(delta):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
[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="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"]
|
||||
radius = 22.4893
|
||||
|
|
|
@ -19,7 +19,7 @@ var required_stamina: int
|
|||
var effectiveness: float
|
||||
|
||||
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):
|
||||
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