From d6d6301c7fd1935b3d4addb3255ef375536080f2 Mon Sep 17 00:00:00 2001 From: Jakob Feldmann Date: Wed, 7 Sep 2022 15:53:34 +0200 Subject: [PATCH] Button that enables a portal and UI timer --- .../contraption}/Coin.gd | 0 .../contraption}/button.png | Bin .../contraption}/button.png.import | 6 +- .../contraption}/buttonStateIndicator.png | Bin .../buttonStateIndicator.png.import | 6 +- src/Autoload/PlayerData.gd | 1 + src/Contraptions/Triggers/ElevatorButton.gd | 24 ++++ src/Contraptions/Triggers/ElevatorButton.tscn | 114 ++++++++++++++++++ .../Triggers}/ThreeWhyButtons.gd | 1 + .../Triggers}/ThreeWhyButtons.tscn | 4 +- .../Triggers}/WhyButton.gd | 0 .../Triggers}/WhyButton.tscn | 2 +- src/Levels/Enemy Test Level.tscn | 2 +- src/Levels/Moveset Test Level.tscn | 2 +- src/Levels/Old Levels/Plattforms Level.tscn | 2 +- src/Levels/Old Levels/Was First Level.tscn | 2 +- src/Levels/TLT Level.tscn | 26 ++-- src/NeutralObjects/Coin.tscn | 4 +- src/UserInterface/Buttons/UI.tscn | 7 -- src/UserInterface/Screens/HUD.gd | 36 ++++++ src/UserInterface/Screens/HUD.tscn | 82 +++++++++++++ .../PauseScreen.gd} | 8 -- .../PauseScreen.tscn} | 14 +-- src/UserInterface/UserInterface.gd | 4 + src/UserInterface/UserInterface.tscn | 16 +++ 25 files changed, 310 insertions(+), 53 deletions(-) rename {src/NeutralObjects => assets/contraption}/Coin.gd (100%) rename {src/NeutralObjects => assets/contraption}/button.png (100%) rename {src/NeutralObjects => assets/contraption}/button.png.import (72%) rename {src/NeutralObjects => assets/contraption}/buttonStateIndicator.png (100%) rename {src/NeutralObjects => assets/contraption}/buttonStateIndicator.png.import (67%) create mode 100644 src/Contraptions/Triggers/ElevatorButton.gd create mode 100644 src/Contraptions/Triggers/ElevatorButton.tscn rename src/{NeutralObjects => Contraptions/Triggers}/ThreeWhyButtons.gd (83%) rename src/{NeutralObjects => Contraptions/Triggers}/ThreeWhyButtons.tscn (74%) rename src/{NeutralObjects => Contraptions/Triggers}/WhyButton.gd (100%) rename src/{NeutralObjects => Contraptions/Triggers}/WhyButton.tscn (98%) delete mode 100644 src/UserInterface/Buttons/UI.tscn create mode 100644 src/UserInterface/Screens/HUD.gd create mode 100644 src/UserInterface/Screens/HUD.tscn rename src/UserInterface/{Buttons/UserInterface.gd => Screens/PauseScreen.gd} (80%) rename src/UserInterface/{Buttons/UserInterface.tscn => Screens/PauseScreen.tscn} (84%) create mode 100644 src/UserInterface/UserInterface.gd create mode 100644 src/UserInterface/UserInterface.tscn diff --git a/src/NeutralObjects/Coin.gd b/assets/contraption/Coin.gd similarity index 100% rename from src/NeutralObjects/Coin.gd rename to assets/contraption/Coin.gd diff --git a/src/NeutralObjects/button.png b/assets/contraption/button.png similarity index 100% rename from src/NeutralObjects/button.png rename to assets/contraption/button.png diff --git a/src/NeutralObjects/button.png.import b/assets/contraption/button.png.import similarity index 72% rename from src/NeutralObjects/button.png.import rename to assets/contraption/button.png.import index c9529c3..ebe27a2 100644 --- a/src/NeutralObjects/button.png.import +++ b/assets/contraption/button.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/button.png-6b06252879983e2da39a6ce37483d567.stex" +path="res://.import/button.png-1c40827a7b86c08339ffad4b8dfd2eca.stex" metadata={ "vram_texture": false } [deps] -source_file="res://src/NeutralObjects/button.png" -dest_files=[ "res://.import/button.png-6b06252879983e2da39a6ce37483d567.stex" ] +source_file="res://assets/contraption/button.png" +dest_files=[ "res://.import/button.png-1c40827a7b86c08339ffad4b8dfd2eca.stex" ] [params] diff --git a/src/NeutralObjects/buttonStateIndicator.png b/assets/contraption/buttonStateIndicator.png similarity index 100% rename from src/NeutralObjects/buttonStateIndicator.png rename to assets/contraption/buttonStateIndicator.png diff --git a/src/NeutralObjects/buttonStateIndicator.png.import b/assets/contraption/buttonStateIndicator.png.import similarity index 67% rename from src/NeutralObjects/buttonStateIndicator.png.import rename to assets/contraption/buttonStateIndicator.png.import index 03a22d5..2595ef3 100644 --- a/src/NeutralObjects/buttonStateIndicator.png.import +++ b/assets/contraption/buttonStateIndicator.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/buttonStateIndicator.png-4ad4dfff1d6add183d62f1b602452b7a.stex" +path="res://.import/buttonStateIndicator.png-ba7e9194bffdad2fd86ec22294cee608.stex" metadata={ "vram_texture": false } [deps] -source_file="res://src/NeutralObjects/buttonStateIndicator.png" -dest_files=[ "res://.import/buttonStateIndicator.png-4ad4dfff1d6add183d62f1b602452b7a.stex" ] +source_file="res://assets/contraption/buttonStateIndicator.png" +dest_files=[ "res://.import/buttonStateIndicator.png-ba7e9194bffdad2fd86ec22294cee608.stex" ] [params] diff --git a/src/Autoload/PlayerData.gd b/src/Autoload/PlayerData.gd index f807795..98cc33e 100644 --- a/src/Autoload/PlayerData.gd +++ b/src/Autoload/PlayerData.gd @@ -3,6 +3,7 @@ extends Node signal score_updated signal player_died +#TODO Easteregg pls var score: = 0 setget set_score var deaths: = 0 setget set_deaths diff --git a/src/Contraptions/Triggers/ElevatorButton.gd b/src/Contraptions/Triggers/ElevatorButton.gd new file mode 100644 index 0000000..e8b0c8a --- /dev/null +++ b/src/Contraptions/Triggers/ElevatorButton.gd @@ -0,0 +1,24 @@ +extends Node2D + +onready var buttonPlayer = $"%ButtonPlayer" +onready var activatorArea = $"%ActivatorArea" +onready var indicatorPlayer = $"%IndicatorPlayer" +onready var elevator = get_node("./Portal") +onready var ui = get_node("../UserInterface") + + +func selfActivate(): + indicatorPlayer.play("onning") + buttonPlayer.play("pushing") + elevator.visible = true + elevator.monitoring = true + #TODO dis importante + activatorArea.set_deferred("monitoring", false) + + +func _on_ActivatorArea_area_entered(_area:Area2D) -> void: + selfActivate() + if ui.has_signal("terminal_activated"): + ui.emit_signal("terminal_activated") + + diff --git a/src/Contraptions/Triggers/ElevatorButton.tscn b/src/Contraptions/Triggers/ElevatorButton.tscn new file mode 100644 index 0000000..64aa059 --- /dev/null +++ b/src/Contraptions/Triggers/ElevatorButton.tscn @@ -0,0 +1,114 @@ +[gd_scene load_steps=9 format=2] + +[ext_resource path="res://src/Contraptions/Triggers/ElevatorButton.gd" type="Script" id=1] + +[sub_resource type="StreamTexture" id=1] +load_path = "res://.import/button.png-6b06252879983e2da39a6ce37483d567.stex" + +[sub_resource type="Animation" id=2] +resource_name = "pushing" +length = 0.5 +tracks/0/type = "value" +tracks/0/path = NodePath(".:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = false +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2, 0.4 ), +"transitions": PoolRealArray( 1, 1, 1 ), +"update": 1, +"values": [ 0.0, 1.0, 2.0 ] +} + +[sub_resource type="StreamTexture" id=17] +load_path = "res://.import/buttonStateIndicator.png-4ad4dfff1d6add183d62f1b602452b7a.stex" + +[sub_resource type="Animation" id=10] +length = 0.1 +tracks/0/type = "value" +tracks/0/path = NodePath(".:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = false +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 1, +"values": [ 0.0 ] +} + +[sub_resource type="Animation" id=13] +resource_name = "onning" +length = 0.6 +tracks/0/type = "value" +tracks/0/path = NodePath(".:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = false +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 0.2, 0.3, 0.5 ), +"transitions": PoolRealArray( 1, 1, 1, 1 ), +"update": 1, +"values": [ 7.0, 8.0, 6.0, 4.0 ] +} + +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 4, 1 ) + +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 6, 1 ) + +[node name="Terminal" type="Node2D"] +script = ExtResource( 1 ) + +[node name="Button" type="Sprite" parent="."] +position = Vector2( 0, -6 ) +texture = SubResource( 1 ) +hframes = 2 +vframes = 2 +__meta__ = { +"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PVNwcml0ZS9BbmltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvbmV1dHJhbCBvYmplY3QvYnV0dG9uLmFzZXByaXRlCmxheWVyfD0Kb3BfZXhwfD1GYWxzZQpvX2ZvbGRlcnw9Cm9fbmFtZXw9Cm9ubHlfdmlzaWJsZXw9RmFsc2UKb19leF9wfD0K" +} + +[node name="ButtonPlayer" type="AnimationPlayer" parent="Button"] +unique_name_in_owner = true +anims/pushing = SubResource( 2 ) + +[node name="Indicator" type="Sprite" parent="."] +position = Vector2( 0, -1 ) +z_index = 1 +texture = SubResource( 17 ) +hframes = 3 +vframes = 3 +__meta__ = { +"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUluZGljYXRvcjIvQW5pbWF0aW9uUGxheWVyCnNvdXJjZXw9cmVzOi8vYXNzZXRzL25ldXRyYWwgb2JqZWN0L2J1dHRvblN0YXRlSW5kaWNhdG9yLmFzZXByaXRlCmxheWVyfD0Kb3BfZXhwfD1GYWxzZQpvX2ZvbGRlcnw9Cm9fbmFtZXw9Cm9ubHlfdmlzaWJsZXw9RmFsc2UKb19leF9wfD0K" +} + +[node name="IndicatorPlayer" type="AnimationPlayer" parent="Indicator"] +unique_name_in_owner = true +anims/offing = SubResource( 10 ) +anims/onning = SubResource( 13 ) + +[node name="ActivatorArea" type="Area2D" parent="."] +unique_name_in_owner = true +position = Vector2( 0, -6 ) +collision_layer = 24 + +[node name="ActivatorAreaShape" type="CollisionShape2D" parent="ActivatorArea"] +unique_name_in_owner = true +position = Vector2( 0, 3 ) +shape = SubResource( 4 ) + +[node name="ButtonBody" type="StaticBody2D" parent="."] +unique_name_in_owner = true +position = Vector2( 0, -6 ) +collision_layer = 24 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="ButtonBody"] +position = Vector2( 0, 5 ) +shape = SubResource( 3 ) + +[connection signal="area_entered" from="ActivatorArea" to="." method="_on_ActivatorArea_area_entered"] diff --git a/src/NeutralObjects/ThreeWhyButtons.gd b/src/Contraptions/Triggers/ThreeWhyButtons.gd similarity index 83% rename from src/NeutralObjects/ThreeWhyButtons.gd rename to src/Contraptions/Triggers/ThreeWhyButtons.gd index 7c8073d..fd3d99c 100644 --- a/src/NeutralObjects/ThreeWhyButtons.gd +++ b/src/Contraptions/Triggers/ThreeWhyButtons.gd @@ -1,5 +1,6 @@ extends Node2D +#TODO Make indipendent from button count #Is emitted in child nodes signal child_button_activated(id) diff --git a/src/NeutralObjects/ThreeWhyButtons.tscn b/src/Contraptions/Triggers/ThreeWhyButtons.tscn similarity index 74% rename from src/NeutralObjects/ThreeWhyButtons.tscn rename to src/Contraptions/Triggers/ThreeWhyButtons.tscn index 56b67fd..6ea89b5 100644 --- a/src/NeutralObjects/ThreeWhyButtons.tscn +++ b/src/Contraptions/Triggers/ThreeWhyButtons.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://src/NeutralObjects/WhyButton.tscn" type="PackedScene" id=1] -[ext_resource path="res://src/NeutralObjects/ThreeWhyButtons.gd" type="Script" id=2] +[ext_resource path="res://src/Contraptions/Triggers/WhyButton.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/Contraptions/Triggers/ThreeWhyButtons.gd" type="Script" id=2] [node name="TreeWhyButtons" type="Node2D"] script = ExtResource( 2 ) diff --git a/src/NeutralObjects/WhyButton.gd b/src/Contraptions/Triggers/WhyButton.gd similarity index 100% rename from src/NeutralObjects/WhyButton.gd rename to src/Contraptions/Triggers/WhyButton.gd diff --git a/src/NeutralObjects/WhyButton.tscn b/src/Contraptions/Triggers/WhyButton.tscn similarity index 98% rename from src/NeutralObjects/WhyButton.tscn rename to src/Contraptions/Triggers/WhyButton.tscn index d3f9f75..a598bca 100644 --- a/src/NeutralObjects/WhyButton.tscn +++ b/src/Contraptions/Triggers/WhyButton.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=15 format=2] -[ext_resource path="res://src/NeutralObjects/WhyButton.gd" type="Script" id=1] +[ext_resource path="res://src/Contraptions/Triggers/WhyButton.gd" type="Script" id=1] [sub_resource type="StreamTexture" id=1] load_path = "res://.import/button.png-6b06252879983e2da39a6ce37483d567.stex" diff --git a/src/Levels/Enemy Test Level.tscn b/src/Levels/Enemy Test Level.tscn index 18c9443..c490220 100644 --- a/src/Levels/Enemy Test Level.tscn +++ b/src/Levels/Enemy Test Level.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=1] [ext_resource path="res://assets/environment/blocks/24BlockBasic.png" type="Texture" id=2] -[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=3] +[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=3] [ext_resource path="res://src/HarmfulObjects/Spikes.tscn" type="PackedScene" id=4] [ext_resource path="res://src/Actors/Enemies/Beings/Enemy.tscn" type="PackedScene" id=5] [ext_resource path="res://src/Actors/Enemies/Beings/SimpleEnemy.tscn" type="PackedScene" id=6] diff --git a/src/Levels/Moveset Test Level.tscn b/src/Levels/Moveset Test Level.tscn index b59286a..b5e90be 100644 --- a/src/Levels/Moveset Test Level.tscn +++ b/src/Levels/Moveset Test Level.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=7 format=2] [ext_resource path="res://assets/environment/blocks/24BlockBasic.png" type="Texture" id=1] -[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=2] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=4] diff --git a/src/Levels/Old Levels/Plattforms Level.tscn b/src/Levels/Old Levels/Plattforms Level.tscn index fb61645..9de63fe 100644 --- a/src/Levels/Old Levels/Plattforms Level.tscn +++ b/src/Levels/Old Levels/Plattforms Level.tscn @@ -5,7 +5,7 @@ [ext_resource path="res://src/Contraptions/Platform/Spring.tscn" type="PackedScene" id=3] [ext_resource path="res://src/Environment/Background.tscn" type="PackedScene" id=4] [ext_resource path="res://src/Contraptions/Platform/Track.tscn" type="PackedScene" id=5] -[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7] +[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=7] [sub_resource type="NavigationPolygon" id=1] vertices = PoolVector2Array( 16, 16, 0, 16, 0, 0, 16, 0 ) diff --git a/src/Levels/Old Levels/Was First Level.tscn b/src/Levels/Old Levels/Was First Level.tscn index 01d7040..28174ce 100644 --- a/src/Levels/Old Levels/Was First Level.tscn +++ b/src/Levels/Old Levels/Was First Level.tscn @@ -4,7 +4,7 @@ [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=2] [ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=3] [ext_resource path="res://src/HarmfulObjects/Spikes.tscn" type="PackedScene" id=6] -[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7] +[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=7] [sub_resource type="ConvexPolygonShape2D" id=3] points = PoolVector2Array( 0, 0, 24, 0, 24, 24, 0, 24 ) diff --git a/src/Levels/TLT Level.tscn b/src/Levels/TLT Level.tscn index a8ef3ce..4f25355 100644 --- a/src/Levels/TLT Level.tscn +++ b/src/Levels/TLT Level.tscn @@ -1,13 +1,14 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://src/Environment/AlienShipTileSet.tres" type="TileSet" id=1] [ext_resource path="res://src/Actors/Blobby/Blobby.tscn" type="PackedScene" id=2] [ext_resource path="res://src/HarmfulObjects/Spikes.tscn" type="PackedScene" id=3] -[ext_resource path="res://src/Contraptions/Platform/FlyingLaserCutter.tscn" type="PackedScene" id=4] +[ext_resource path="res://src/Contraptions/Triggers/ElevatorButton.tscn" type="PackedScene" id=4] [ext_resource path="res://src/Contraptions/Portal/Portal.tscn" type="PackedScene" id=5] [ext_resource path="res://src/NeutralObjects/Coin.tscn" type="PackedScene" id=6] -[ext_resource path="res://src/UserInterface/Buttons/UI.tscn" type="PackedScene" id=7] -[ext_resource path="res://src/NeutralObjects/ThreeWhyButtons.tscn" type="PackedScene" id=8] +[ext_resource path="res://src/UserInterface/UserInterface.tscn" type="PackedScene" id=7] +[ext_resource path="res://src/Contraptions/Triggers/ThreeWhyButtons.tscn" type="PackedScene" id=8] +[ext_resource path="res://src/Levels/Enemy Test Level.tscn" type="PackedScene" id=9] [sub_resource type="AnimationNodeStateMachinePlayback" id=4] @@ -20,18 +21,12 @@ __meta__ = { [node name="UserInterface" parent="." instance=ExtResource( 7 )] [node name="Blobby" parent="." instance=ExtResource( 2 )] +position = Vector2( -60, -3.8147e-06 ) scale = Vector2( 0.878906, 0.936025 ) [node name="AnimationTree" parent="Blobby/BlobbySprite" index="0"] parameters/playback = SubResource( 4 ) -[node name="FlyingLaserCutter" parent="." instance=ExtResource( 4 )] -position = Vector2( 80, 80 ) -rotation = 1.5708 - -[node name="Portal" parent="." instance=ExtResource( 5 )] -position = Vector2( 1428, -110 ) - [node name="Collectibles" type="Node2D" parent="."] [node name="Coin" parent="Collectibles" instance=ExtResource( 6 )] @@ -104,6 +99,15 @@ rotation = 3.14159 position = Vector2( 1452, -77 ) rotation = -1.5708 +[node name="ElevatorButton" parent="." instance=ExtResource( 4 )] +position = Vector2( 1452, -96 ) + +[node name="Portal" parent="ElevatorButton" instance=ExtResource( 5 )] +visible = false +position = Vector2( -1464, 84 ) +monitoring = false +next_scene = ExtResource( 9 ) + [editable path="Blobby"] [editable path="TreeWhyButtons"] [editable path="TreeWhyButtons/WhyButton1"] diff --git a/src/NeutralObjects/Coin.tscn b/src/NeutralObjects/Coin.tscn index 6bb4754..1e1f2e6 100644 --- a/src/NeutralObjects/Coin.tscn +++ b/src/NeutralObjects/Coin.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=320 format=2] [ext_resource path="res://assets/neutral object/whitegold orbicle/0020 (Klein)-fs8.png" type="Texture" id=1] -[ext_resource path="res://src/NeutralObjects/Coin.gd" type="Script" id=2] +[ext_resource path="res://assets/contraption/Coin.gd" type="Script" id=2] [ext_resource path="res://assets/neutral object/whitegold orbicle/0021 (Klein)-fs8.png" type="Texture" id=3] [ext_resource path="res://assets/neutral object/whitegold orbicle/0023 (Klein)-fs8.png" type="Texture" id=4] [ext_resource path="res://assets/neutral object/whitegold orbicle/0025 (Klein)-fs8.png" type="Texture" id=5] @@ -407,7 +407,7 @@ position = Vector2( 0, -2.52127 ) scale = Vector2( 0.149428, 0.151196 ) frames = SubResource( 4 ) animation = "rotate" -frame = 250 +frame = 176 playing = true [connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/src/UserInterface/Buttons/UI.tscn b/src/UserInterface/Buttons/UI.tscn deleted file mode 100644 index 93e2b4f..0000000 --- a/src/UserInterface/Buttons/UI.tscn +++ /dev/null @@ -1,7 +0,0 @@ -[gd_scene load_steps=2 format=2] - -[ext_resource path="res://src/UserInterface/Buttons/UserInterface.tscn" type="PackedScene" id=1] - -[node name="UserInterface" type="CanvasLayer"] - -[node name="UserInterface" parent="." instance=ExtResource( 1 )] diff --git a/src/UserInterface/Screens/HUD.gd b/src/UserInterface/Screens/HUD.gd new file mode 100644 index 0000000..ef887b3 --- /dev/null +++ b/src/UserInterface/Screens/HUD.gd @@ -0,0 +1,36 @@ +extends Control + +# Smart ist es die notwendigen Resourcen vor dem Skriptstart zu laden +onready var current_scene := get_tree().get_current_scene() +onready var pause_overlay: ColorRect = $HUDOverlay +onready var timer: Label = $HUDOverlay/GetBackTimer +onready var score: Label = $HUDOverlay/Score + + +func _ready(): + #TODO Connect what HOW? + PlayerData.connect("score_updated", self, "update_interface") + update_interface() + +func _process(delta): + if timer.visible: + timer.text = String(round($HUDOverlay/GetBackTimer/Timer.time_left)) + +func start_timer(): + timer.visible = true + $HUDOverlay/GetBackTimer/Timer.start() + $HUDOverlay/GetBackTimer/AnimationPlayer.play("Redlight") + _zoom_timer() + + +func _zoom_timer() -> void: + var tween := create_tween() + tween.tween_property(timer, "rect_scale", Vector2(1,1), 1.0) + + +func update_interface() -> void: + score.text = "Score: %s" % PlayerData.score + + +func _on_UserInterface_terminal_activated() -> void: + start_timer() diff --git a/src/UserInterface/Screens/HUD.tscn b/src/UserInterface/Screens/HUD.tscn new file mode 100644 index 0000000..43d45de --- /dev/null +++ b/src/UserInterface/Screens/HUD.tscn @@ -0,0 +1,82 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://assets/meta/ui_theme.tres" type="Theme" id=1] +[ext_resource path="res://src/UserInterface/Screens/HUD.gd" type="Script" id=5] + +[sub_resource type="Animation" id=1] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("..:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Color( 0, 0, 0, 0 ) ] +} + +[sub_resource type="Animation" id=2] +resource_name = "Redlight" +length = 2.0 +loop = true +tracks/0/type = "value" +tracks/0/path = NodePath("..:color") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Color( 0.423529, 0, 0, 0.160784 ), Color( 0, 0, 0, 0 ) ] +} + +[node name="HUD" type="Control"] +pause_mode = 2 +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +theme = ExtResource( 1 ) +script = ExtResource( 5 ) + +[node name="HUDOverlay" type="ColorRect" parent="."] +unique_name_in_owner = true +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -320.0 +margin_right = 320.0 +margin_bottom = 360.0 +color = Color( 0, 0, 0, 0 ) + +[node name="Score" type="Label" parent="HUDOverlay"] +unique_name_in_owner = true +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -96.0001 +rect_scale = Vector2( 0.590909, 0.627907 ) +text = "Score: 100000000000000000" +align = 2 + +[node name="GetBackTimer" type="Label" parent="HUDOverlay"] +unique_name_in_owner = true +visible = false +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -9.0 +margin_right = 9.0 +margin_bottom = 14.0 +rect_scale = Vector2( 5, 5 ) +text = "100" +align = 2 + +[node name="Timer" type="Timer" parent="HUDOverlay/GetBackTimer"] +wait_time = 100.0 +one_shot = true + +[node name="AnimationPlayer" type="AnimationPlayer" parent="HUDOverlay/GetBackTimer"] +anims/RESET = SubResource( 1 ) +anims/Redlight = SubResource( 2 ) diff --git a/src/UserInterface/Buttons/UserInterface.gd b/src/UserInterface/Screens/PauseScreen.gd similarity index 80% rename from src/UserInterface/Buttons/UserInterface.gd rename to src/UserInterface/Screens/PauseScreen.gd index 3ac4ed2..0a3b3f9 100644 --- a/src/UserInterface/Buttons/UserInterface.gd +++ b/src/UserInterface/Screens/PauseScreen.gd @@ -3,16 +3,12 @@ extends Control # Smart ist es die notwendigen Resourcen vor dem Skriptstart zu laden onready var current_scene := get_tree().get_current_scene() onready var pause_overlay: ColorRect = get_node("PauseOverlay") -onready var score: Label = get_node("Label") onready var pause_title: Label = get_node("PauseOverlay/Title") var paused := false setget set_paused - func _ready(): - PlayerData.connect("score_updated", self, "update_interface") PlayerData.connect("player_died", self, "_on_PlayerData_player_died") - update_interface() func _on_PlayerData_player_died() -> void: @@ -28,10 +24,6 @@ func _unhandled_input(event: InputEvent) -> void: get_tree().set_input_as_handled() -func update_interface() -> void: - score.text = "Score: %s" % PlayerData.score - - func set_paused(value: bool) -> void: paused = value get_tree().paused = value diff --git a/src/UserInterface/Buttons/UserInterface.tscn b/src/UserInterface/Screens/PauseScreen.tscn similarity index 84% rename from src/UserInterface/Buttons/UserInterface.tscn rename to src/UserInterface/Screens/PauseScreen.tscn index 3e3090b..8473265 100644 --- a/src/UserInterface/Buttons/UserInterface.tscn +++ b/src/UserInterface/Screens/PauseScreen.tscn @@ -4,9 +4,9 @@ [ext_resource path="res://src/UserInterface/Buttons/QuitButton.tscn" type="PackedScene" id=2] [ext_resource path="res://src/UserInterface/Buttons/ChangeSceneButton.tscn" type="PackedScene" id=3] [ext_resource path="res://src/UserInterface/Buttons/RetryButton.tscn" type="PackedScene" id=4] -[ext_resource path="res://src/UserInterface/Buttons/UserInterface.gd" type="Script" id=5] +[ext_resource path="res://src/UserInterface/Screens/PauseScreen.gd" type="Script" id=5] -[node name="UserInterface" type="Control"] +[node name="PauseScreen" type="Control"] pause_mode = 2 anchor_right = 1.0 anchor_bottom = 1.0 @@ -69,13 +69,3 @@ margin_bottom = 15.0 size_flags_horizontal = 0 size_flags_vertical = 0 text = "Pause" - -[node name="Label" type="Label" parent="."] -anchor_left = 1.0 -anchor_right = 1.0 -margin_left = -96.0001 -margin_right = -17.0001 -margin_bottom = 24.0 -rect_scale = Vector2( 0.590909, 0.627907 ) -text = "Score: %s" -align = 2 diff --git a/src/UserInterface/UserInterface.gd b/src/UserInterface/UserInterface.gd new file mode 100644 index 0000000..881b621 --- /dev/null +++ b/src/UserInterface/UserInterface.gd @@ -0,0 +1,4 @@ +extends CanvasLayer + +signal terminal_activated() + diff --git a/src/UserInterface/UserInterface.tscn b/src/UserInterface/UserInterface.tscn new file mode 100644 index 0000000..4f2e4a5 --- /dev/null +++ b/src/UserInterface/UserInterface.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/UserInterface/Screens/PauseScreen.tscn" type="PackedScene" id=1] +[ext_resource path="res://src/UserInterface/Screens/HUD.tscn" type="PackedScene" id=2] +[ext_resource path="res://src/UserInterface/UserInterface.gd" type="Script" id=3] + +[node name="UserInterface" type="CanvasLayer"] +layer = 2 +script = ExtResource( 3 ) + +[node name="HUD" parent="." instance=ExtResource( 2 )] + +[node name="PauseScreen" parent="." instance=ExtResource( 1 )] +mouse_filter = 1 + +[connection signal="terminal_activated" from="." to="HUD" method="_on_UserInterface_terminal_activated"]