Merge remote-tracking branch 'remotes/origin/main' into feat_game_over
This commit is contained in:
commit
762c9a945d
|
@ -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)
|
||||
|
|
|
@ -27,10 +27,19 @@ func _process(delta):
|
|||
global_position = Vector2(boundary.get_most_left_position(), global_position.y)
|
||||
|
||||
|
||||
func _on_joke_button_button_pressed(joke):
|
||||
func _on_joke_button_button_pressed(joke: Joke):
|
||||
stamina -= joke.required_stamina
|
||||
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue