From cb9b905227db773f83f8ba2878a51d92f1641e75 Mon Sep 17 00:00:00 2001 From: Waldemar Tomme Date: Sun, 28 Jan 2024 12:19:52 +0100 Subject: [PATCH 1/2] People outside target area now also stop losing mood while a joke is told --- godot/scenes/Tim.gd | 22 ++++++++++++++-------- godot/scenes/crowd/person.gd | 8 +++++--- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/godot/scenes/Tim.gd b/godot/scenes/Tim.gd index 1c09618..9d9a2b7 100644 --- a/godot/scenes/Tim.gd +++ b/godot/scenes/Tim.gd @@ -44,7 +44,7 @@ func _on_joke_button_button_pressed(joke: Joke): last_joke = joke stamina -= joke.required_stamina _disable_buttons() - _start_joke_for_audience(false) + _start_joke_for_audience() $AnimationPlayer.play("talking") func _get_targeted_audience_members(target_all: bool): @@ -65,13 +65,17 @@ func _get_targeted_audience_members_in_target_area() -> Array[AudienceMember]: arr.append(person) return arr -func _start_joke_for_audience(target_all: bool): - for person in _get_targeted_audience_members(target_all): +func _start_joke_for_audience(): + for person in _get_targeted_audience_members(true): person.on_joke_start() -func _finish_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): - person.on_joke_finish(joke) + person.on_hear_joke(joke) + +func _finish_joke_for_audience(): + for person in _get_targeted_audience_members(true): + person.on_joke_finish() func _on_stamina_empty(): get_node("../DisplayGUI").visible = false @@ -92,13 +96,15 @@ func _on_stamina_empty(): func ouch(): $Sprite2D.texture = ducking_texture - _start_joke_for_audience(true) + _start_joke_for_audience() await get_tree().create_timer(1).timeout $Sprite2D.texture = default_texture - _finish_joke_for_audience(Joke.get_bottle_joke(), true) + _tell_joke_for_audience(Joke.get_bottle_joke(), true) + _finish_joke_for_audience() func _on_animation_player_animation_finished(anim_name): - _finish_joke_for_audience(last_joke, false) + _tell_joke_for_audience(last_joke, false) + _finish_joke_for_audience() if stamina <= 0: _on_stamina_empty() else: diff --git a/godot/scenes/crowd/person.gd b/godot/scenes/crowd/person.gd index 888178e..465259a 100644 --- a/godot/scenes/crowd/person.gd +++ b/godot/scenes/crowd/person.gd @@ -140,15 +140,17 @@ func set_random_face(): func on_joke_start(): is_listening = true - -func on_joke_finish(joke: Joke): - is_listening = false + +func on_hear_joke(joke: Joke): var mood_change = profile.joke_mood_mapping.get(joke.type, 0) 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 + func throw_bottle(): mood += 2.0 From d44ac6ee02570f10967686bd0cc33a3f57505c3c Mon Sep 17 00:00:00 2001 From: Marvin Dalheimer Date: Sun, 28 Jan 2024 12:32:09 +0100 Subject: [PATCH 2/2] Add a spotlight for Tim --- godot/scenes/Boundary.gd | 8 +++- godot/scenes/boot/bootsplash_scene.gd | 36 +++++++++++------- godot/scenes/crowd/crowd.gd | 5 ++- godot/scenes/crowd/crowd.tscn | 6 ++- godot/scenes/stage.tscn | 12 +++++- godot/sprites/ui/spotlight.svg | 54 +++++++++++++++++++++++++++ godot/sprites/ui/spotlight.svg.import | 37 ++++++++++++++++++ 7 files changed, 138 insertions(+), 20 deletions(-) create mode 100644 godot/sprites/ui/spotlight.svg create mode 100644 godot/sprites/ui/spotlight.svg.import diff --git a/godot/scenes/Boundary.gd b/godot/scenes/Boundary.gd index 6861257..cd54d2b 100644 --- a/godot/scenes/Boundary.gd +++ b/godot/scenes/Boundary.gd @@ -3,16 +3,20 @@ extends Node2D @export var width = 200. + # Called when the node enters the scene tree for the first time. func _ready(): - pass # Replace with function body. + pass # Replace with function body. + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): pass + func get_most_left_position(): return global_position.x - width / 2 - + + func get_most_right_position(): return global_position.x + width / 2 diff --git a/godot/scenes/boot/bootsplash_scene.gd b/godot/scenes/boot/bootsplash_scene.gd index 58f0858..f8ef250 100644 --- a/godot/scenes/boot/bootsplash_scene.gd +++ b/godot/scenes/boot/bootsplash_scene.gd @@ -1,14 +1,15 @@ class_name BootsplashScene extends Control -@export var fade_duration:float = 1.0 -@export var stay_duration:float = 1.5 -@export var node:PackedScene -@export var next_scene:PackedScene -@export var interuptable:bool = true +@export var fade_duration: float = 1.0 +@export var stay_duration: float = 1.5 +@export var node: PackedScene +@export var next_scene: PackedScene +@export var interuptable: bool = true @onready var control = %NodeContainer -@onready var instance:Node2D = node.instantiate() +@onready var instance: Node2D = node.instantiate() + func _ready(): instance.modulate.a = 0.0 @@ -16,21 +17,28 @@ func _ready(): var tween = create_tween() tween.set_trans(Tween.TRANS_CUBIC) tween.set_ease(Tween.EASE_IN) - tween.tween_property(instance, "modulate:a", 1.0, fade_duration)\ - .from(0.0)\ - .finished.connect(_fade_out) - + tween.tween_property(instance, "modulate:a", 1.0, fade_duration).from(0.0).finished.connect( + _fade_out + ) + + func _process(_delta): if interuptable and Input.is_action_just_pressed("exit"): _change_scene() - + + func _fade_out(): var tween = create_tween() tween.set_trans(Tween.TRANS_CUBIC) tween.set_ease(Tween.EASE_IN) - tween.tween_property(instance, "modulate:a", 0.0, fade_duration)\ - .set_delay(stay_duration)\ - .finished.connect(_change_scene) + ( + tween + . tween_property(instance, "modulate:a", 0.0, fade_duration) + . set_delay(stay_duration) + . finished + . connect(_change_scene) + ) + func _change_scene(): get_tree().change_scene_to_packed(next_scene) diff --git a/godot/scenes/crowd/crowd.gd b/godot/scenes/crowd/crowd.gd index 04621ae..9c6a0a6 100644 --- a/godot/scenes/crowd/crowd.gd +++ b/godot/scenes/crowd/crowd.gd @@ -3,9 +3,9 @@ extends Node2D @export_range(1, 16, 1) var max_persons = 16 +var audience: Array[AudienceMember] = [] +var overall_mood: float = 0 -var audience : Array[AudienceMember] = [] -var overall_mood : float = 0 func _ready(): var counter = 0 @@ -20,6 +20,7 @@ func _ready(): if counter == max_persons: break + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta): overall_mood = 0 diff --git a/godot/scenes/crowd/crowd.tscn b/godot/scenes/crowd/crowd.tscn index 9cedd4e..5101ffb 100644 --- a/godot/scenes/crowd/crowd.tscn +++ b/godot/scenes/crowd/crowd.tscn @@ -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" uid="uid://bbehbuw5lvfkr" path="res://sprites/room/chair.tscn" id="3_y4hpm"] +[ext_resource type="PackedScene" path="res://sprites/room/chair.tscn" id="3_y4hpm"] [node name="Crowd" type="Node2D"] position = Vector2(240, 232) @@ -131,3 +131,7 @@ z_index = 46 position = Vector2(237, 15) [node name="Chair" parent="Seats/Seat_16" instance=ExtResource("3_y4hpm")] + +[node name="CanvasModulate" type="CanvasModulate" parent="."] +show_behind_parent = true +color = Color(0.494118, 0.494118, 0.494118, 1) diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index 9afff0c..0a5cac7 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -1,10 +1,11 @@ -[gd_scene load_steps=18 format=3 uid="uid://cicyfp5xjvvu4"] +[gd_scene load_steps=19 format=3 uid="uid://cicyfp5xjvvu4"] [ext_resource type="Texture2D" uid="uid://bg85if5rrrdmm" path="res://sprites/room/buehne.svg" id="1_32lst"] [ext_resource type="Script" path="res://scenes/Tim.gd" id="1_g3k2b"] [ext_resource type="Texture2D" uid="uid://kq63ictuirhc" path="res://sprites/tim_side.png" id="1_saxit"] [ext_resource type="Script" path="res://scenes/Boundary.gd" id="2_8p6ir"] [ext_resource type="PackedScene" uid="uid://r1i7ln2hpwq5" path="res://scenes/joke_button.tscn" id="3_0t41i"] +[ext_resource type="Texture2D" uid="uid://bmx2q0w1s046n" path="res://sprites/ui/spotlight.svg" id="3_8lu50"] [ext_resource type="Texture2D" uid="uid://b8tb4o75kjffn" path="res://sprites/tim_talk.svg" id="3_e1fvx"] [ext_resource type="Script" path="res://scenes/DisplayStamina.gd" id="6_88orn"] [ext_resource type="FontFile" uid="uid://le2vdo2626vw" path="res://fonts/Montserrat-Medium.ttf" id="6_pb3a7"] @@ -121,9 +122,18 @@ action = "joke_button_3" [node name="Joke Transmitter" type="Node2D" parent="Tim"] +[node name="Spotlight" type="PointLight2D" parent="Tim/Joke Transmitter"] +self_modulate = Color(1, 1, 1, 0) +show_behind_parent = true +z_index = -20 +position = Vector2(2.08165e-12, -500) +energy = 0.4 +texture = ExtResource("3_8lu50") + [node name="Area2D" type="Area2D" parent="Tim/Joke Transmitter"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Tim/Joke Transmitter/Area2D"] +position = Vector2(0, -176) shape = SubResource("RectangleShape2D_wmfel") [node name="AnimationPlayer" type="AnimationPlayer" parent="Tim"] diff --git a/godot/sprites/ui/spotlight.svg b/godot/sprites/ui/spotlight.svg new file mode 100644 index 0000000..ce64ad2 --- /dev/null +++ b/godot/sprites/ui/spotlight.svg @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + diff --git a/godot/sprites/ui/spotlight.svg.import b/godot/sprites/ui/spotlight.svg.import new file mode 100644 index 0000000..b30741e --- /dev/null +++ b/godot/sprites/ui/spotlight.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bmx2q0w1s046n" +path="res://.godot/imported/spotlight.svg-f6d684577e7bd3fc0fb3e8fdd58e1327.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/ui/spotlight.svg" +dest_files=["res://.godot/imported/spotlight.svg-f6d684577e7bd3fc0fb3e8fdd58e1327.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false