From d13d76411ce4502e656d33adc55c9e2991549382 Mon Sep 17 00:00:00 2001 From: Willow Behar <2364126-TechRunner@users.noreply.gitlab.com> Date: Sun, 2 Jun 2024 15:27:47 -0500 Subject: [PATCH] Made Loading screen it's own component instead of being part of the player and made it part of the game --- Assets/components/loading_screen.tscn | 39 ++++++++++++++++++++++++++ Assets/components/player.tscn | 40 ++------------------------- Assets/game.tscn | 7 ++++- Assets/scripts/LoadingScreen.gd | 7 +++-- 4 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 Assets/components/loading_screen.tscn diff --git a/Assets/components/loading_screen.tscn b/Assets/components/loading_screen.tscn new file mode 100644 index 0000000..205b67f --- /dev/null +++ b/Assets/components/loading_screen.tscn @@ -0,0 +1,39 @@ +[gd_scene load_steps=3 format=3 uid="uid://dnihn8hn7dc4f"] + +[ext_resource type="Theme" uid="uid://dnoxpn5kedvxh" path="res://Assets/Resources/VCRFont.tres" id="1_7378h"] +[ext_resource type="Script" path="res://Assets/scripts/LoadingScreen.gd" id="2_7qlq6"] + +[node name="LoadingScreen" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("1_7378h") +script = ExtResource("2_7qlq6") + +[node name="Blackout" type="ColorRect" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0, 0, 0, 1) + +[node name="Label" type="Label" parent="Blackout"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_font_sizes/font_size = 80 +text = "Loading..." +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="Timer" type="Timer" parent="."] + +[connection signal="timeout" from="Timer" to="." method="_on_timer_timeout"] diff --git a/Assets/components/player.tscn b/Assets/components/player.tscn index 2893176..db48d98 100644 --- a/Assets/components/player.tscn +++ b/Assets/components/player.tscn @@ -1,14 +1,12 @@ -[gd_scene load_steps=7 format=3 uid="uid://bcjijcf8br8t4"] +[gd_scene load_steps=5 format=3 uid="uid://bcjijcf8br8t4"] [ext_resource type="Script" path="res://Assets/scripts/player.gd" id="1_b2ij4"] [ext_resource type="Script" path="res://Assets/scripts/Head.gd" id="2_is0vo"] [ext_resource type="Script" path="res://Assets/scripts/vapelight.gd" id="2_ndvgb"] -[ext_resource type="Script" path="res://Assets/scripts/LoadingScreen.gd" id="4_1bb8i"] -[ext_resource type="Theme" uid="uid://dnoxpn5kedvxh" path="res://Assets/Resources/VCRFont.tres" id="4_7cvtk"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_lm3xc"] -[node name="Player" type="CharacterBody3D"] +[node name="Player" type="CharacterBody3D" groups=["Player"]] script = ExtResource("1_b2ij4") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] @@ -44,41 +42,7 @@ wait_time = 5.0 [node name="Severe Coughing Recovery" type="Timer" parent="."] wait_time = 15.0 -[node name="LoadingScreen" type="Control" parent="."] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme = ExtResource("4_7cvtk") -script = ExtResource("4_1bb8i") - -[node name="Blackout" type="ColorRect" parent="LoadingScreen"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -color = Color(0, 0, 0, 1) - -[node name="Label" type="Label" parent="LoadingScreen/Blackout"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_font_sizes/font_size = 80 -text = "Loading..." -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="Timer" type="Timer" parent="LoadingScreen"] - [connection signal="timeout" from="Severe Coughing Timer" to="." method="_on_severe_coughing_timer_timeout"] [connection signal="timeout" from="Coughing Timer" to="." method="_on_coughing_timer_timeout"] [connection signal="timeout" from="Coughing Recovery" to="." method="_on_coughing_recovery_timeout"] [connection signal="timeout" from="Severe Coughing Recovery" to="." method="_on_severe_coughing_recovery_timeout"] -[connection signal="timeout" from="LoadingScreen/Timer" to="LoadingScreen" method="_on_timer_timeout"] diff --git a/Assets/game.tscn b/Assets/game.tscn index 7cfd57c..0c9a62c 100644 --- a/Assets/game.tscn +++ b/Assets/game.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=9 format=3 uid="uid://dc26wfgxnhsnh"] +[gd_scene load_steps=10 format=3 uid="uid://dc26wfgxnhsnh"] [ext_resource type="Script" path="res://Assets/scripts/game.gd" id="1_l82qa"] [ext_resource type="PackedScene" uid="uid://dy3tsag0bcs4n" path="res://Assets/components/game_over.tscn" id="2_6q1xr"] [ext_resource type="PackedScene" uid="uid://bwo6gvmi3jcqt" path="res://Assets/components/Pause Screen.tscn" id="2_j4ays"] +[ext_resource type="PackedScene" uid="uid://dnihn8hn7dc4f" path="res://Assets/components/loading_screen.tscn" id="2_r4o7n"] [ext_resource type="PackedScene" uid="uid://bcjijcf8br8t4" path="res://Assets/components/player.tscn" id="3_g384r"] [ext_resource type="Script" path="res://Assets/scripts/MapLoader.gd" id="4_cjwjg"] [ext_resource type="PackedScene" uid="uid://b2knd58e85mif" path="res://Assets/Levels/Apartment.tscn" id="6_gytet"] @@ -12,6 +13,9 @@ [node name="Game" type="Node3D"] script = ExtResource("1_l82qa") +[node name="LoadingScreen" parent="." instance=ExtResource("2_r4o7n")] +visible = false + [node name="Game Over" parent="." instance=ExtResource("2_6q1xr")] visible = false @@ -27,3 +31,4 @@ scenes = Array[PackedScene]([ExtResource("6_gytet"), ExtResource("7_krx07"), Ext [connection signal="paused" from="Pause Menu" to="." method="_on_pause_menu_paused"] [connection signal="unpaused" from="Pause Menu" to="." method="_on_pause_menu_unpaused"] +[connection signal="map_loaded" from="Map" to="player" method="_on_map_map_loaded"] diff --git a/Assets/scripts/LoadingScreen.gd b/Assets/scripts/LoadingScreen.gd index 119a88f..61623dd 100644 --- a/Assets/scripts/LoadingScreen.gd +++ b/Assets/scripts/LoadingScreen.gd @@ -1,10 +1,11 @@ extends Control -func _init(): - show() - func _ready(): + show() $Timer.start() func _on_timer_timeout(): hide() + +func LoadingDone(): + hide()