Merge branch 'main' into feature/tim_animation
# Conflicts: # godot/scenes/Tim.gd # godot/scenes/stage.tscn
This commit is contained in:
commit
fe5436c9ab
|
@ -0,0 +1,17 @@
|
|||
extends Label
|
||||
|
||||
var audience: Array[AudienceMember] = []
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
for seat in get_node("/root/IngameScene/Crowd/Seats").get_children():
|
||||
audience.append(seat.get_node("Person"))
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
var mood = 0
|
||||
for m in audience:
|
||||
mood += m.mood
|
||||
text = str(int(mood))
|
|
@ -0,0 +1,7 @@
|
|||
extends Label
|
||||
|
||||
@onready var Tim : Comedian = get_node("../../Tim")
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
text = str(int(max(0, Tim.stamina)))
|
|
@ -5,27 +5,37 @@ signal button_pressed(joke)
|
|||
@export_enum("joke_button_1", "joke_button_2", "joke_button_3") var action: String
|
||||
@export var sprite: Sprite2D
|
||||
|
||||
@export var stamina_categories: Array[int]
|
||||
@export var type_sprites: Array[Texture2D]
|
||||
|
||||
var stamina_label: RichTextLabel
|
||||
|
||||
var current_joke: Joke
|
||||
|
||||
func _map_action_to_joke():
|
||||
func _map_action_to_joke_type():
|
||||
match action:
|
||||
"joke_button_1":
|
||||
return Joke.new(Joke.JokeType.Joke1)
|
||||
return Joke.JokeType.Joke1
|
||||
"joke_button_2":
|
||||
return Joke.new(Joke.JokeType.Joke2)
|
||||
return Joke.JokeType.Joke2
|
||||
"joke_button_3":
|
||||
return Joke.new(Joke.JokeType.Joke3)
|
||||
return Joke.JokeType.Joke3
|
||||
|
||||
func _get_joke(type):
|
||||
return Joke.new(type, stamina_categories[randi_range(0, stamina_categories.size() - 1)])
|
||||
|
||||
func _ready():
|
||||
set_current_joke(_map_action_to_joke())
|
||||
stamina_label = find_child("StaminaLabel")
|
||||
set_current_joke(_get_joke(_map_action_to_joke_type()))
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed(action):
|
||||
button_pressed.emit(current_joke)
|
||||
set_current_joke(_get_joke(_map_action_to_joke_type()))
|
||||
|
||||
func set_current_joke(joke: Joke):
|
||||
current_joke = joke
|
||||
sprite.texture = type_sprites[joke.type]
|
||||
stamina_label.text = "%s" % joke.required_stamina
|
||||
print("stamina: ", joke.required_stamina)
|
||||
|
|
|
@ -1,43 +1,56 @@
|
|||
class_name Comedian
|
||||
extends Node2D
|
||||
|
||||
@export var move_speed = 100
|
||||
@export var boundary: Boundary
|
||||
@export var tim_sprite : Sprite2D
|
||||
@export var tim_sprite: Sprite2D
|
||||
@export var transmitter_area: Area2D
|
||||
@export var stamina: int = 100
|
||||
|
||||
var default_texture: Texture2D = load("res://sprites/tim_side.png")
|
||||
var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg")
|
||||
|
||||
|
||||
# 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 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 _on_joke_button_button_pressed(joke):
|
||||
$AnimationPlayer.play("talking")
|
||||
func _on_joke_button_button_pressed(joke: Joke):
|
||||
$AnimationPlayer.play("talking")
|
||||
stamina -= joke.required_stamina
|
||||
|
||||
for body in transmitter_area.get_overlapping_bodies():
|
||||
var person = body.find_parent("Person")
|
||||
if not (person is AudienceMember):
|
||||
continue
|
||||
for body in transmitter_area.get_overlapping_bodies():
|
||||
var person = body.find_parent("Person")
|
||||
if not (person is AudienceMember):
|
||||
continue
|
||||
|
||||
person.on_joke(joke)
|
||||
|
||||
if stamina <= 0:
|
||||
_on_stamina_empty()
|
||||
|
||||
|
||||
func _on_stamina_empty():
|
||||
pass
|
||||
|
||||
person.on_joke(joke)
|
||||
|
||||
func ouch():
|
||||
$Sprite2D.texture = ducking_texture
|
||||
await get_tree().create_timer(1).timeout
|
||||
$Sprite2D.texture = default_texture
|
||||
$Sprite2D.texture = ducking_texture
|
||||
await get_tree().create_timer(1).timeout
|
||||
$Sprite2D.texture = default_texture
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class_name AudienceProfile
|
||||
extends Node2D
|
||||
|
||||
|
||||
class ProfileData:
|
||||
var happy_threshold: float
|
||||
var angry_threshold: float
|
||||
|
@ -9,7 +10,14 @@ class ProfileData:
|
|||
var lashout_decay: float
|
||||
var joke_mood_mapping: Dictionary
|
||||
|
||||
func _init(happy_threshold, angry_threshold, lashout_threshold, happiness_decay, lashout_decay, joke_mood_mapping):
|
||||
func _init(
|
||||
happy_threshold,
|
||||
angry_threshold,
|
||||
lashout_threshold,
|
||||
happiness_decay,
|
||||
lashout_decay,
|
||||
joke_mood_mapping
|
||||
):
|
||||
self.happy_threshold = happy_threshold
|
||||
self.angry_threshold = angry_threshold
|
||||
self.lashout_threshold = lashout_threshold
|
||||
|
@ -17,32 +25,37 @@ class ProfileData:
|
|||
self.lashout_decay = lashout_decay
|
||||
self.joke_mood_mapping = joke_mood_mapping
|
||||
|
||||
var happy_threshold : float
|
||||
var angry_threshold : float
|
||||
var lashout_threshold : float
|
||||
|
||||
var happiness_decay : float
|
||||
var lashout_decay : float
|
||||
var happy_threshold: float
|
||||
var angry_threshold: float
|
||||
var lashout_threshold: float
|
||||
|
||||
var happiness_decay: float
|
||||
var lashout_decay: float
|
||||
|
||||
# Maps JokeType (as int) to mood change (as float)
|
||||
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}),
|
||||
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}),
|
||||
]
|
||||
return profiles[index]
|
||||
|
||||
|
||||
# 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 load_data(data: ProfileData):
|
||||
happy_threshold = data.happy_threshold
|
||||
angry_threshold = data.angry_threshold
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
extends Node2D
|
||||
|
||||
@export_range(1, 16, 1)
|
||||
var max_persons = 16
|
||||
@export_range(1, 16, 1) var max_persons = 16
|
||||
|
||||
|
||||
func _ready():
|
||||
var counter = 0
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -3,6 +3,7 @@ extends Node2D
|
|||
@onready var fade_overlay = %FadeOverlay
|
||||
@onready var pause_overlay = %PauseOverlay
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
fade_overlay.visible = true
|
||||
|
||||
|
@ -11,6 +12,7 @@ func _ready() -> void:
|
|||
|
||||
pause_overlay.game_exited.connect(_save_game)
|
||||
|
||||
|
||||
func _input(event) -> void:
|
||||
if event.is_action_pressed("pause") and not pause_overlay.visible:
|
||||
get_viewport().set_input_as_handled()
|
||||
|
@ -18,5 +20,6 @@ func _input(event) -> void:
|
|||
pause_overlay.grab_button_focus()
|
||||
pause_overlay.visible = true
|
||||
|
||||
|
||||
func _save_game() -> void:
|
||||
SaveGame.save_game(get_tree())
|
||||
|
|
|
@ -9,7 +9,13 @@
|
|||
script = ExtResource("1_lofpb")
|
||||
action = "joke_button_1"
|
||||
sprite = NodePath("Sprite2D")
|
||||
stamina_categories = Array[int]([1, 5, 10])
|
||||
type_sprites = Array[Texture2D]([ExtResource("3_26ki8"), ExtResource("2_ivsb5"), ExtResource("4_o1r21")])
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_ivsb5")
|
||||
|
||||
[node name="StaminaLabel" type="RichTextLabel" parent="."]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
text = "xx"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://cicyfp5xjvvu4"]
|
||||
[gd_scene load_steps=17 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"]
|
||||
|
@ -6,7 +6,9 @@
|
|||
[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://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="Texture2D" uid="uid://d2264dy2o4q6d" path="res://sprites/tim_side.svg" id="6_qpa7m"]
|
||||
[ext_resource type="Script" path="res://scenes/DisplayMood.gd" id="7_5m0td"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_jfw8v"]
|
||||
radius = 23.0217
|
||||
|
@ -14,22 +16,6 @@ radius = 23.0217
|
|||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_wmfel"]
|
||||
size = Vector2(250, 10000)
|
||||
|
||||
[sub_resource type="Animation" id="Animation_kkrfv"]
|
||||
resource_name = "talking"
|
||||
length = 4.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 3.95),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit")]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_n0bwh"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
|
@ -60,6 +46,22 @@ tracks/0/keys = {
|
|||
"values": [ExtResource("6_qpa7m"), ExtResource("6_qpa7m")]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_kkrfv"]
|
||||
resource_name = "talking"
|
||||
length = 4.0
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Sprite2D:texture")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 3.95),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
|
||||
"update": 1,
|
||||
"values": [ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("6_qpa7m"), ExtResource("3_e1fvx"), ExtResource("1_saxit")]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_xvfym"]
|
||||
_data = {
|
||||
"RESET": SubResource("Animation_n0bwh"),
|
||||
|
@ -67,6 +69,9 @@ _data = {
|
|||
"talking": SubResource("Animation_kkrfv")
|
||||
}
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_aq472"]
|
||||
font_size = 32
|
||||
|
||||
[node name="Stage" type="Node2D"]
|
||||
z_index = 100
|
||||
|
||||
|
@ -128,6 +133,32 @@ libraries = {
|
|||
[node name="Boundary" type="Node2D" parent="."]
|
||||
script = ExtResource("2_8p6ir")
|
||||
|
||||
[node name="DisplayGUI" type="CanvasLayer" parent="."]
|
||||
follow_viewport_enabled = true
|
||||
|
||||
[node name="Stamina" type="Label" parent="DisplayGUI"]
|
||||
offset_right = 80.0
|
||||
offset_bottom = 46.0
|
||||
text = "100"
|
||||
label_settings = SubResource("LabelSettings_aq472")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
script = ExtResource("6_88orn")
|
||||
|
||||
[node name="Mood" type="Label" parent="DisplayGUI"]
|
||||
anchors_preset = 1
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -170.0
|
||||
offset_right = -10.0
|
||||
offset_bottom = 46.0
|
||||
grow_horizontal = 0
|
||||
text = "0"
|
||||
label_settings = SubResource("LabelSettings_aq472")
|
||||
horizontal_alignment = 2
|
||||
vertical_alignment = 1
|
||||
script = ExtResource("7_5m0td")
|
||||
|
||||
[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 1" to="Tim" method="_on_joke_button_button_pressed"]
|
||||
[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 2" to="Tim" method="_on_joke_button_button_pressed"]
|
||||
[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 3" to="Tim" method="_on_joke_button_button_pressed"]
|
||||
|
|
|
@ -7,6 +7,8 @@ enum JokeType {
|
|||
}
|
||||
|
||||
var type: JokeType
|
||||
var required_stamina: int
|
||||
|
||||
func _init(type):
|
||||
func _init(type, required_stamina):
|
||||
self.type = type
|
||||
self.required_stamina = required_stamina
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue