endgame done

This commit is contained in:
Mikhail Aristov 2024-01-27 21:10:50 +01:00
parent 762c9a945d
commit 1f125ed467
8 changed files with 103 additions and 54 deletions

View File

@ -1,15 +1,7 @@
extends Label extends Label
var audience : Array[AudienceMember] = [] @onready var crowd_controller: Crowd = get_node("/root/IngameScene/Crowd")
# 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. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(_delta):
var mood = 0 text = str(int(crowd_controller.overall_mood))
for m in audience:
mood += m.mood
text = str(int(mood))

View File

@ -42,4 +42,16 @@ func _on_joke_button_button_pressed(joke: Joke):
_on_stamina_empty() _on_stamina_empty()
func _on_stamina_empty(): func _on_stamina_empty():
pass get_node("../DisplayGUI").visible = false
var fade = get_node("/root/IngameScene/UI/FadeOverlay")
fade.modulate.a = fade.minimum_opacity
fade.visible = 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

View File

@ -1,8 +1,12 @@
class_name Crowd
extends Node2D extends Node2D
@export_range(1, 16, 1) @export_range(1, 16, 1)
var max_persons = 16 var max_persons = 16
var audience : Array[AudienceMember] = []
var overall_mood : float = 0
func _ready(): func _ready():
var counter = 0 var counter = 0
var person = preload("res://scenes/crowd/person.tscn") var person = preload("res://scenes/crowd/person.tscn")
@ -10,7 +14,14 @@ func _ready():
var person_node = person.instantiate() var person_node = person.instantiate()
person_node.color = AudienceMember.get_random_color() person_node.color = AudienceMember.get_random_color()
seat.add_child(person_node) seat.add_child(person_node)
audience.append(person_node)
counter += 1 counter += 1
if counter == max_persons: if counter == max_persons:
break break
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
overall_mood = 0
for m in audience:
overall_mood += m.mood

View File

@ -2,7 +2,7 @@
[ext_resource type="Script" path="res://scenes/crowd/crowd.gd" id="1_y7wyj"] [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="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"] [node name="Crowd" type="Node2D"]
position = Vector2(240, 232) position = Vector2(240, 232)

View File

@ -10,6 +10,13 @@
[node name="IngameScene" type="Node2D"] [node name="IngameScene" type="Node2D"]
script = ExtResource("1_objyc") script = ExtResource("1_objyc")
[node name="Crowd" parent="." instance=ExtResource("4_aeh13")]
position = Vector2(261, 230)
[node name="Stage" parent="." instance=ExtResource("5_borcq")]
z_index = 10
position = Vector2(291, 346)
[node name="UI" type="CanvasLayer" parent="."] [node name="UI" type="CanvasLayer" parent="."]
[node name="FadeOverlay" parent="UI" instance=ExtResource("1_y6ebv")] [node name="FadeOverlay" parent="UI" instance=ExtResource("1_y6ebv")]
@ -24,12 +31,3 @@ visible = false
unique_name_in_owner = true unique_name_in_owner = true
process_mode = 2 process_mode = 2
visible = false visible = false
[node name="Crowd" parent="." instance=ExtResource("4_aeh13")]
visible = false
position = Vector2(0, 0)
[node name="Stage" parent="." instance=ExtResource("5_borcq")]
visible = false
z_index = 10
position = Vector2(291, 346)

View File

@ -0,0 +1,23 @@
extends CenterContainer
signal game_exited
@onready var new_game_button := %NewGameButton
@onready var exit_button := %ExitButton
# Called when the node enters the scene tree for the first time.
func _ready():
new_game_button.pressed.connect(_new_game)
exit_button.pressed.connect(_exit)
func grab_button_focus() -> void:
new_game_button.grab_focus()
func _new_game() -> void:
get_tree().paused = false
get_tree().change_scene_to_file("res://scenes/ingame_scene.tscn")
func _exit() -> void:
game_exited.emit()
get_tree().quit()

View File

@ -1,4 +1,6 @@
[gd_scene format=3 uid="uid://b0xc4jjyahlvk"] [gd_scene load_steps=2 format=3 uid="uid://b0xc4jjyahlvk"]
[ext_resource type="Script" path="res://scenes/score_overlay.gd" id="1_8s0ln"]
[node name="ScoreOverlay" type="CenterContainer"] [node name="ScoreOverlay" type="CenterContainer"]
process_mode = 2 process_mode = 2
@ -7,6 +9,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("1_8s0ln")
[node name="VBoxContainer3" type="VBoxContainer" parent="."] [node name="VBoxContainer3" type="VBoxContainer" parent="."]
layout_mode = 2 layout_mode = 2
@ -35,7 +38,7 @@ unique_name_in_owner = true
layout_mode = 2 layout_mode = 2
theme_override_constants/separation = 8 theme_override_constants/separation = 8
[node name="MainMenuButton" type="Button" parent="VBoxContainer3/MenuContainer"] [node name="NewGameButton" type="Button" parent="VBoxContainer3/MenuContainer"]
unique_name_in_owner = true unique_name_in_owner = true
custom_minimum_size = Vector2(180, 0) custom_minimum_size = Vector2(180, 0)
layout_mode = 2 layout_mode = 2

File diff suppressed because one or more lines are too long