From ac65b1a446d3264a49b7efc874f82673cb3cbed6 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 5 Apr 2022 01:32:49 +0200 Subject: [PATCH] :bug: Fix replay button --- src/entities/players/PhaseOnePlayer.tscn | 8 +++++++- src/levels/Game.gd | 18 ++++++++++++------ src/levels/endings/GoodEnding.tscn | 4 ++-- src/levels/ui/UserInterface.tscn | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/entities/players/PhaseOnePlayer.tscn b/src/entities/players/PhaseOnePlayer.tscn index d1c2520..8cd450e 100644 --- a/src/entities/players/PhaseOnePlayer.tscn +++ b/src/entities/players/PhaseOnePlayer.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://src/entities/players/AbstractPlayer.tscn" type="PackedScene" id=1] [ext_resource path="res://src/behaviours/spawning/ShootOnClick.tscn" type="PackedScene" id=2] @@ -7,6 +7,7 @@ [ext_resource path="res://src/entities/players/CharacterFrontLeft.png" type="Texture" id=5] [ext_resource path="res://src/entities/players/CharacterFront.png" type="Texture" id=6] [ext_resource path="res://src/behaviours/graphics/FourSidedSprite.gd" type="Script" id=7] +[ext_resource path="res://src/mechanics/Light.png" type="Texture" id=8] [sub_resource type="CapsuleShape2D" id=3] radius = 9.0 @@ -59,4 +60,9 @@ container_name = "Bullets" [node name="ShootOnClick" parent="SpawnOnShoot" index="2" instance=ExtResource( 2 )] +[node name="Light" type="Light2D" parent="." index="5"] +texture = ExtResource( 8 ) +texture_scale = 0.1 +color = Color( 1, 1, 1, 0.12549 ) + [connection signal="moved_in_direction" from="PlayerMovement" to="Shape/FourSidedSprite" method="_on_PlayerMovement_moved_in_direction"] diff --git a/src/levels/Game.gd b/src/levels/Game.gd index 595d5e7..4e44334 100644 --- a/src/levels/Game.gd +++ b/src/levels/Game.gd @@ -4,13 +4,15 @@ extends Node2D export(PackedScene) var main_menu = preload("res://src/levels/mainmenu/MainMenu.tscn") export(PackedScene) var phase_one = preload("res://src/levels/phaseone/PhaseOne.tscn") export(PackedScene) var user_interface = preload("res://src/levels/ui/UserInterface.tscn") +export(PackedScene) var bad_ending = preload("res://src/levels/endings/BadEnding.tscn") +export(PackedScene) var good_ending = preload("res://src/levels/endings/GoodEnding.tscn") func _ready(): print("Starting from the menu!") add_child(main_menu.instance()) # warning-ignore: RETURN_VALUE_DISCARDED - $MainMenu/TheDarkNightUI/Play.connect("pressed", self, "_on_MainMenu_Play_pressed") + $MainMenu/TheDarkNightUI/Play.connect("pressed", self, "_on_MainMenu_Play_pressed", []) func _on_MainMenu_Play_pressed(): @@ -19,25 +21,27 @@ func _on_MainMenu_Play_pressed(): func _on_Fire_died(_origin, _value): - print("Should move to the second phase...") - $PhaseOne.queue_free() + $UserInterface.queue_free() add_child(bad_ending.instance()) # warning-ignore: RETURN_VALUE_DISCARDED - $BadEnding/TheDarkNightUI/Play.connect("pressed", self, "_on_BadEnding_Replay_pressed") + $BadEnding/TheDarkNightUI/Play.connect("pressed", self, "_on_BadEnding_Replay_pressed", []) + func _on_Player_died(_origin, _value): print("Should display a bad end...") - $PhaseOne.queue_free() + $UserInterface.queue_free() add_child(bad_ending.instance()) # warning-ignore: RETURN_VALUE_DISCARDED - $BadEnding/TheDarkNightUI/Play.connect("pressed", self, "_on_BadEnding_Replay_pressed") + $BadEnding/TheDarkNightUI/Play.connect("pressed", self, "_on_BadEnding_Replay_pressed", []) + func _on_BadEnding_Replay_pressed(): $BadEnding.queue_free() _on_Play_pressed() + func _on_Play_pressed(): print("Moving to the first phase...") add_child(phase_one.instance()) @@ -52,3 +56,5 @@ func _on_Play_pressed(): $UserInterface/TheDarkNightUI/MuteButton.connect("toggled", $Music, "_on_MuteButton_toggled") # warning-ignore: RETURN_VALUE_DISCARDED $PhaseOne/Entities/PhaseOnePlayer/Damageable.connect("health_changed", $UserInterface/TheDarkNightUI/HealthBar, "_on_PhaseOnePlayer_health_changed") + # warning-ignore: RETURN_VALUE_DISCARDED + $PhaseOne/Entities/PhaseOnePlayer/Damageable.connect("health_reached_min", self, "_on_Player_died") diff --git a/src/levels/endings/GoodEnding.tscn b/src/levels/endings/GoodEnding.tscn index af0f42d..ff6eb10 100644 --- a/src/levels/endings/GoodEnding.tscn +++ b/src/levels/endings/GoodEnding.tscn @@ -84,7 +84,7 @@ margin_top = 300.0 position = Vector2( 421, -275 ) scale = Vector2( 4, 4 ) -[node name="Damaging" parent="TheDarkNightUI/MenuFire" index="3"] -damage = -5.0 +[node name="FlameSprite" parent="TheDarkNightUI/MenuFire/Flame/Shape" index="0"] +frame = 0 [editable path="TheDarkNightUI/MenuFire"] diff --git a/src/levels/ui/UserInterface.tscn b/src/levels/ui/UserInterface.tscn index bbd5948..49f83f3 100644 --- a/src/levels/ui/UserInterface.tscn +++ b/src/levels/ui/UserInterface.tscn @@ -51,7 +51,7 @@ align = 2 valign = 1 script = ExtResource( 4 ) -[node name="TextureProgress" type="TextureProgress" parent="TheDarkNightUI"] +[node name="HealthBar" type="TextureProgress" parent="TheDarkNightUI"] margin_left = 15.0 margin_top = 15.0 margin_right = 365.0