Add end screen! It’s beautiful!
This commit is contained in:
parent
01dc50193c
commit
ec958717b1
4 changed files with 79 additions and 0 deletions
28
scenes/end_screen.gd
Normal file
28
scenes/end_screen.gd
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
extends CanvasLayer
|
||||
|
||||
var _score := 0
|
||||
var _saved := 0
|
||||
|
||||
func _ready():
|
||||
visible = false
|
||||
EventBus.game_won.connect(_on_game_won)
|
||||
EventBus.game_lost.connect(_on_game_lost)
|
||||
EventBus.score_changed.connect(func(s): _score = s)
|
||||
EventBus.saved_changed.connect(func(s): _saved = s)
|
||||
$Center/Card/Margin/Column/RestartButton.pressed.connect(_on_restart_pressed)
|
||||
|
||||
func _on_game_won():
|
||||
$Center/Card/Margin/Column/Headline.text = "YOU ESCAPED"
|
||||
_show()
|
||||
|
||||
func _on_game_lost():
|
||||
$Center/Card/Margin/Column/Headline.text = "TOO FEW"
|
||||
_show()
|
||||
|
||||
func _show():
|
||||
$Center/Card/Margin/Column/ScoreLabel.text = "Score: %d" % _score
|
||||
$Center/Card/Margin/Column/SavedLabel.text = "Survivors saved: %d" % _saved
|
||||
visible = true
|
||||
|
||||
func _on_restart_pressed():
|
||||
get_tree().reload_current_scene()
|
||||
1
scenes/end_screen.gd.uid
Normal file
1
scenes/end_screen.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cpewgbefcp3wn
|
||||
47
scenes/end_screen.tscn
Normal file
47
scenes/end_screen.tscn
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/end_screen.gd" id="1"]
|
||||
|
||||
[node name="EndScreen" type="CanvasLayer"]
|
||||
layer = 10
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Dim" type="ColorRect" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
color = Color(0, 0, 0, 0.7)
|
||||
|
||||
[node name="Center" type="CenterContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 1
|
||||
|
||||
[node name="Card" type="PanelContainer" parent="Center"]
|
||||
|
||||
[node name="Margin" type="MarginContainer" parent="Center/Card"]
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_right = 40
|
||||
theme_override_constants/margin_top = 32
|
||||
theme_override_constants/margin_bottom = 32
|
||||
|
||||
[node name="Column" type="VBoxContainer" parent="Center/Card/Margin"]
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="Headline" type="Label" parent="Center/Card/Margin/Column"]
|
||||
text = "YOU ESCAPED"
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 48
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="Center/Card/Margin/Column"]
|
||||
text = "Score: 0"
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 24
|
||||
|
||||
[node name="SavedLabel" type="Label" parent="Center/Card/Margin/Column"]
|
||||
text = "Survivors saved: 0"
|
||||
horizontal_alignment = 1
|
||||
theme_override_font_sizes/font_size = 24
|
||||
|
||||
[node name="RestartButton" type="Button" parent="Center/Card/Margin/Column"]
|
||||
text = "RESTART"
|
||||
|
|
@ -8,6 +8,7 @@
|
|||
[ext_resource type="AudioStream" uid="uid://bavo8f76jr7i6" path="res://audio/ElevatorOpen1.wav" id="5_u5sy4"]
|
||||
[ext_resource type="AudioStream" uid="uid://dgqb1rovgwuan" path="res://audio/ElevatorClose1.wav" id="6_gee14"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/component_spawn.tscn" id="9_0tnpc"]
|
||||
[ext_resource type="PackedScene" path="res://scenes/end_screen.tscn" id="10_endsc"]
|
||||
|
||||
[node name="Game" type="Node3D" unique_id=1456297160]
|
||||
script = ExtResource("1_lbhrr")
|
||||
|
|
@ -35,3 +36,5 @@ stream = ExtResource("6_gee14")
|
|||
[node name="SfxChase" type="AudioStreamPlayer3D" parent="CanvasPanel/ElevatorPanel" unique_id=812445001]
|
||||
|
||||
[node name="ComponentSpawn" parent="." unique_id=649225939 instance=ExtResource("9_0tnpc")]
|
||||
|
||||
[node name="EndScreen" parent="." instance=ExtResource("10_endsc")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue