From 64fcffb0f2dcf88e1fb4d576d00c626def40f91e Mon Sep 17 00:00:00 2001 From: Waldemar Tomme Date: Sun, 28 Jan 2024 11:51:33 +0100 Subject: [PATCH] Bottles are now jokes --- godot/scenes/Tim.gd | 25 ++++++++++++++++++------- godot/scenes/crowd/audience_profile.gd | 6 +++--- godot/types/joke.gd | 6 +++++- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/godot/scenes/Tim.gd b/godot/scenes/Tim.gd index 7447bc9..1c09618 100644 --- a/godot/scenes/Tim.gd +++ b/godot/scenes/Tim.gd @@ -44,10 +44,19 @@ func _on_joke_button_button_pressed(joke: Joke): last_joke = joke stamina -= joke.required_stamina _disable_buttons() - _start_joke_for_audience() + _start_joke_for_audience(false) $AnimationPlayer.play("talking") -func _get_targeted_audience_members() -> Array[AudienceMember]: +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() + +func _get_all_targeted_audience_members() -> Array[AudienceMember]: + 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") @@ -56,12 +65,12 @@ func _get_targeted_audience_members() -> Array[AudienceMember]: arr.append(person) return arr -func _start_joke_for_audience(): - for person in _get_targeted_audience_members(): +func _start_joke_for_audience(target_all: bool): + for person in _get_targeted_audience_members(target_all): person.on_joke_start() -func _finish_joke_for_audience(joke: Joke): - for person in _get_targeted_audience_members(): +func _finish_joke_for_audience(joke: Joke, target_all: bool): + for person in _get_targeted_audience_members(target_all): person.on_joke_finish(joke) func _on_stamina_empty(): @@ -83,11 +92,13 @@ func _on_stamina_empty(): func ouch(): $Sprite2D.texture = ducking_texture + _start_joke_for_audience(true) await get_tree().create_timer(1).timeout $Sprite2D.texture = default_texture + _finish_joke_for_audience(Joke.get_bottle_joke(), true) func _on_animation_player_animation_finished(anim_name): - _finish_joke_for_audience(last_joke) + _finish_joke_for_audience(last_joke, false) if stamina <= 0: _on_stamina_empty() else: diff --git a/godot/scenes/crowd/audience_profile.gd b/godot/scenes/crowd/audience_profile.gd index 74cbcc0..8f8203a 100644 --- a/godot/scenes/crowd/audience_profile.gd +++ b/godot/scenes/crowd/audience_profile.gd @@ -39,9 +39,9 @@ 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}), - ProfileData.new(3, -3, -10, 0.1, 0.1, {0: 0, 1: 1, 2: -0.25}), - ProfileData.new(3, -3, -10, 0.1, 0.1, {0: -0.25, 1: 0, 2: 1}), + 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}), ] return profiles[index] diff --git a/godot/types/joke.gd b/godot/types/joke.gd index 3c6c33a..515bc6a 100644 --- a/godot/types/joke.gd +++ b/godot/types/joke.gd @@ -3,12 +3,16 @@ class_name Joke enum JokeType { Joke1 = 0, Joke2, - Joke3 + Joke3, + Bottle, } var type: JokeType var required_stamina: int +static func get_bottle_joke(): + return Joke.new(JokeType.Bottle, 0) + func _init(type, required_stamina): self.type = type self.required_stamina = required_stamina