Added game over

This commit is contained in:
Marco 2025-04-01 11:23:37 +02:00
commit 8151298b44
14 changed files with 160 additions and 35 deletions

Binary file not shown.

BIN
ExternalMaterial/FairyDefeated/GameOver.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://3spfcuok2po2"
path="res://.godot/imported/GameOver.png-c9dca459ca730525becf7b5edd35a8c9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://ExternalMaterial/FairyDefeated/GameOver.png"
dest_files=["res://.godot/imported/GameOver.png-c9dca459ca730525becf7b5edd35a8c9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -48,6 +48,7 @@ MaxHealth = 2.0
MovementSpeed = 30.0 MovementSpeed = 30.0
Weapon = ExtResource("7_xkg5o") Weapon = ExtResource("7_xkg5o")
LootDrops = Array[ExtResource("2_sxbtw")]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")]) LootDrops = Array[ExtResource("2_sxbtw")]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")])
MotivationReward = 4.0
PlayerDetectionRange = 90.0 PlayerDetectionRange = 90.0
ViewRange = 120.0 ViewRange = 120.0
AlarmReactRange = 150.0 AlarmReactRange = 150.0

View file

@ -48,6 +48,7 @@ MaxHealth = 4.0
MovementSpeed = 40.0 MovementSpeed = 40.0
Weapon = ExtResource("7_xlxdc") Weapon = ExtResource("7_xlxdc")
LootDrops = Array[ExtResource("2_ivudp")]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")]) LootDrops = Array[ExtResource("2_ivudp")]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")])
MotivationReward = 4.0
PlayerDetectionRange = 90.0 PlayerDetectionRange = 90.0
ViewRange = 120.0 ViewRange = 120.0
AlarmReactRange = 150.0 AlarmReactRange = 150.0

View file

@ -1,5 +1,6 @@
[gd_resource type="Resource" script_class="EnemyResource" load_steps=3 format=3 uid="uid://cfdvg162u65sr"] [gd_resource type="Resource" script_class="EnemyResource" load_steps=4 format=3 uid="uid://cfdvg162u65sr"]
[ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="1_f3huq"]
[ext_resource type="Resource" uid="uid://cdfmedtgp2rcn" path="res://Resources/Weapons/EnemyWeapon.tres" id="7_filx8"] [ext_resource type="Resource" uid="uid://cdfmedtgp2rcn" path="res://Resources/Weapons/EnemyWeapon.tres" id="7_filx8"]
[ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="8_x8scf"] [ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="8_x8scf"]
@ -11,7 +12,8 @@ PrefabPath = &"res://Scenes/Actors/Thermathron.tscn"
MaxHealth = 8.0 MaxHealth = 8.0
MovementSpeed = 38.0 MovementSpeed = 38.0
Weapon = ExtResource("7_filx8") Weapon = ExtResource("7_filx8")
LootDrops = [] LootDrops = Array[ExtResource("1_f3huq")]([])
MotivationReward = 4.0
PlayerDetectionRange = 90.0 PlayerDetectionRange = 90.0
ViewRange = 120.0 ViewRange = 120.0
AlarmReactRange = 200.0 AlarmReactRange = 200.0

View file

@ -1,5 +1,6 @@
[gd_resource type="Resource" script_class="EnemyResource" load_steps=3 format=3 uid="uid://ysd6wl2gmdhn"] [gd_resource type="Resource" script_class="EnemyResource" load_steps=4 format=3 uid="uid://ysd6wl2gmdhn"]
[ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="1_sma76"]
[ext_resource type="Resource" uid="uid://dyaxm3st70sh6" path="res://Resources/Weapons/Enemy/TurretWeapon.tres" id="1_yap8t"] [ext_resource type="Resource" uid="uid://dyaxm3st70sh6" path="res://Resources/Weapons/Enemy/TurretWeapon.tres" id="1_yap8t"]
[ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="2_sma76"] [ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="2_sma76"]
@ -11,7 +12,8 @@ PrefabPath = &"res://Scenes/Actors/Turret360.tscn"
MaxHealth = 14.0 MaxHealth = 14.0
MovementSpeed = 0.0 MovementSpeed = 0.0
Weapon = ExtResource("1_yap8t") Weapon = ExtResource("1_yap8t")
LootDrops = [] LootDrops = Array[ExtResource("1_sma76")]([])
MotivationReward = 4.0
PlayerDetectionRange = 90.0 PlayerDetectionRange = 90.0
ViewRange = 120.0 ViewRange = 120.0
AlarmReactRange = 200.0 AlarmReactRange = 200.0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=3 uid="uid://dkwi1hu1bixoe"] [gd_scene load_steps=36 format=3 uid="uid://dkwi1hu1bixoe"]
[ext_resource type="Script" uid="uid://baf6pxbvhqmjk" path="res://Scripts/Hud.cs" id="1_m0hb0"] [ext_resource type="Script" uid="uid://baf6pxbvhqmjk" path="res://Scripts/Hud.cs" id="1_m0hb0"]
[ext_resource type="PackedScene" uid="uid://cd3ee1adstcrw" path="res://Scenes/HUD/HudItemContainer.tscn" id="2_mattb"] [ext_resource type="PackedScene" uid="uid://cd3ee1adstcrw" path="res://Scenes/HUD/HudItemContainer.tscn" id="2_mattb"]
@ -14,6 +14,7 @@
[ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="9_sx5r0"] [ext_resource type="Theme" uid="uid://dnsadvmunm76k" path="res://Resources/Styles/MainMenuButtons.tres" id="9_sx5r0"]
[ext_resource type="StyleBox" uid="uid://dnb4ogn847dyp" path="res://Resources/Styles/HealthBarBackground.tres" id="10_n0pka"] [ext_resource type="StyleBox" uid="uid://dnb4ogn847dyp" path="res://Resources/Styles/HealthBarBackground.tres" id="10_n0pka"]
[ext_resource type="Script" uid="uid://bobo5f4ud60qw" path="res://Scripts/UI/ItemsMenu.cs" id="10_oflr6"] [ext_resource type="Script" uid="uid://bobo5f4ud60qw" path="res://Scripts/UI/ItemsMenu.cs" id="10_oflr6"]
[ext_resource type="Texture2D" uid="uid://3spfcuok2po2" path="res://ExternalMaterial/FairyDefeated/GameOver.png" id="10_s015s"]
[ext_resource type="Script" uid="uid://com5b4ffsmj7s" path="res://Scripts/UI/InventoryMenu.cs" id="11_7pulb"] [ext_resource type="Script" uid="uid://com5b4ffsmj7s" path="res://Scripts/UI/InventoryMenu.cs" id="11_7pulb"]
[ext_resource type="StyleBox" uid="uid://6ydsirgc5xi5" path="res://Resources/Styles/HealthBarFill.tres" id="11_j6myr"] [ext_resource type="StyleBox" uid="uid://6ydsirgc5xi5" path="res://Resources/Styles/HealthBarFill.tres" id="11_j6myr"]
[ext_resource type="Texture2D" uid="uid://bhmtp6i2g2f1c" path="res://Sprites/UI/ShieldBar.png" id="12_n0pka"] [ext_resource type="Texture2D" uid="uid://bhmtp6i2g2f1c" path="res://Sprites/UI/ShieldBar.png" id="12_n0pka"]
@ -85,24 +86,58 @@ texture_margin_bottom = 3.0
[sub_resource type="LabelSettings" id="LabelSettings_bkqle"] [sub_resource type="LabelSettings" id="LabelSettings_bkqle"]
font_color = Color(0, 0.737255, 0.113725, 1) font_color = Color(0, 0.737255, 0.113725, 1)
[node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_healthLabel", "_healthBar", "_shieldLabel", "_shieldBar", "_motivationLabel", "_itemsContainer", "_gameOverPanel", "PauseMenuContainer", "DebugMenuHolder")] [node name="HUD" type="CanvasLayer" node_paths=PackedStringArray("_healthLabel", "_healthBar", "_shieldLabel", "_shieldBar", "_motivationLabel", "_itemsContainer", "_gameOverPanel", "_fairyTerminatedPanel", "_hudInfoPanel", "PauseMenuContainer", "DebugMenuHolder")]
process_mode = 3 process_mode = 3
script = ExtResource("1_m0hb0") script = ExtResource("1_m0hb0")
WeaponContainerTemplate = ExtResource("2_mattb") WeaponContainerTemplate = ExtResource("2_mattb")
ItemNotificationTemplate = ExtResource("3_mw35l") ItemNotificationTemplate = ExtResource("3_mw35l")
_healthLabel = NodePath("VBoxContainer/HealthBarContainer/HealthLabel") _healthLabel = NodePath("HudInfo/HealthBarContainer/HealthLabel")
_healthBar = NodePath("VBoxContainer/HealthBarContainer/HealthBar") _healthBar = NodePath("HudInfo/HealthBarContainer/HealthBar")
_shieldLabel = NodePath("VBoxContainer/ShieldBarContainer/ShieldLabel") _shieldLabel = NodePath("HudInfo/ShieldBarContainer/ShieldLabel")
_shieldBar = NodePath("VBoxContainer/ShieldBarContainer/ShieldBar") _shieldBar = NodePath("HudInfo/ShieldBarContainer/ShieldBar")
_motivationLabel = NodePath("VBoxContainer/MotivationContainer/Motivationlabel") _motivationLabel = NodePath("HudInfo/MotivationContainer/Motivationlabel")
_itemsContainer = NodePath("VBoxContainer/ItemsContainer") _itemsContainer = NodePath("HudInfo/ItemsContainer")
_labelSettings = ExtResource("2_x7kl7") _labelSettings = ExtResource("2_x7kl7")
_gameOverPanel = NodePath("GameOver") _gameOverPanel = NodePath("GameOver")
_fairyTerminatedPanel = NodePath("FairyTerminated")
_hudInfoPanel = NodePath("HudInfo")
PauseMenuContainer = NodePath("PauseMenuContainer") PauseMenuContainer = NodePath("PauseMenuContainer")
PauseMenuScene = ExtResource("3_hxmxt") PauseMenuScene = ExtResource("3_hxmxt")
DebugMenuTemplate = ExtResource("4_gd1k6") DebugMenuTemplate = ExtResource("4_gd1k6")
DebugMenuHolder = NodePath("DebugContainer") DebugMenuHolder = NodePath("DebugContainer")
[node name="FairyTerminated" type="PanelContainer" parent="."]
visible = false
offset_left = -3.0
offset_top = 34.0
offset_right = 323.0
offset_bottom = 88.0
[node name="VBoxContainer2" type="VBoxContainer" parent="FairyTerminated"]
layout_mode = 2
size_flags_vertical = 4
theme_override_constants/separation = -4
[node name="GameOver" type="Label" parent="FairyTerminated/VBoxContainer2"]
visible = false
layout_mode = 2
text = "FAIRY: TERMINATED"
label_settings = SubResource("LabelSettings_a7f6n")
horizontal_alignment = 1
[node name="TextureRect" type="TextureRect" parent="FairyTerminated/VBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("8_3523e")
stretch_mode = 2
[node name="Label" type="Label" parent="FairyTerminated/VBoxContainer2"]
visible = false
layout_mode = 2
text = "Press Shoot button to reform"
label_settings = SubResource("LabelSettings_5na8k")
horizontal_alignment = 1
[node name="GameOver" type="PanelContainer" parent="."] [node name="GameOver" type="PanelContainer" parent="."]
visible = false visible = false
offset_left = -3.0 offset_left = -3.0
@ -125,7 +160,7 @@ horizontal_alignment = 1
[node name="TextureRect" type="TextureRect" parent="GameOver/VBoxContainer2"] [node name="TextureRect" type="TextureRect" parent="GameOver/VBoxContainer2"]
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 4 size_flags_horizontal = 4
texture = ExtResource("8_3523e") texture = ExtResource("10_s015s")
stretch_mode = 2 stretch_mode = 2
[node name="Label" type="Label" parent="GameOver/VBoxContainer2"] [node name="Label" type="Label" parent="GameOver/VBoxContainer2"]
@ -146,7 +181,7 @@ sprite_frames = SubResource("SpriteFrames_78fwv")
frame = 1 frame = 1
frame_progress = 0.8514 frame_progress = 0.8514
[node name="VBoxContainer" type="VBoxContainer" parent="."] [node name="HudInfo" type="VBoxContainer" parent="."]
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
@ -160,10 +195,10 @@ size_flags_horizontal = 3
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/separation = 0 theme_override_constants/separation = 0
[node name="HealthBarContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="HealthBarContainer" type="HBoxContainer" parent="HudInfo"]
layout_mode = 2 layout_mode = 2
[node name="HealthBar" type="ProgressBar" parent="VBoxContainer/HealthBarContainer"] [node name="HealthBar" type="ProgressBar" parent="HudInfo/HealthBarContainer"]
custom_minimum_size = Vector2(34, 8) custom_minimum_size = Vector2(34, 8)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 4 size_flags_vertical = 4
@ -173,16 +208,16 @@ value = 50.0
rounded = true rounded = true
show_percentage = false show_percentage = false
[node name="HealthLabel" type="Label" parent="VBoxContainer/HealthBarContainer"] [node name="HealthLabel" type="Label" parent="HudInfo/HealthBarContainer"]
layout_mode = 2 layout_mode = 2
text = "100/100" text = "100/100"
label_settings = ExtResource("2_x7kl7") label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1 vertical_alignment = 1
[node name="ShieldBarContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="ShieldBarContainer" type="HBoxContainer" parent="HudInfo"]
layout_mode = 2 layout_mode = 2
[node name="ShieldBar" type="ProgressBar" parent="VBoxContainer/ShieldBarContainer"] [node name="ShieldBar" type="ProgressBar" parent="HudInfo/ShieldBarContainer"]
custom_minimum_size = Vector2(34, 8) custom_minimum_size = Vector2(34, 8)
layout_mode = 2 layout_mode = 2
size_flags_vertical = 4 size_flags_vertical = 4
@ -191,27 +226,27 @@ theme_override_styles/fill = SubResource("StyleBoxTexture_5cvcb")
value = 50.0 value = 50.0
show_percentage = false show_percentage = false
[node name="ShieldLabel" type="Label" parent="VBoxContainer/ShieldBarContainer"] [node name="ShieldLabel" type="Label" parent="HudInfo/ShieldBarContainer"]
layout_mode = 2 layout_mode = 2
text = "100/100" text = "100/100"
label_settings = ExtResource("2_x7kl7") label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1 vertical_alignment = 1
[node name="MotivationContainer" type="HBoxContainer" parent="VBoxContainer"] [node name="MotivationContainer" type="HBoxContainer" parent="HudInfo"]
layout_mode = 2 layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/MotivationContainer"] [node name="Label" type="Label" parent="HudInfo/MotivationContainer"]
layout_mode = 2 layout_mode = 2
text = "Motivation:" text = "Motivation:"
label_settings = ExtResource("2_x7kl7") label_settings = ExtResource("2_x7kl7")
[node name="Motivationlabel" type="Label" parent="VBoxContainer/MotivationContainer"] [node name="Motivationlabel" type="Label" parent="HudInfo/MotivationContainer"]
layout_mode = 2 layout_mode = 2
text = "100%" text = "100%"
label_settings = ExtResource("2_x7kl7") label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1 vertical_alignment = 1
[node name="ItemsContainer" type="VBoxContainer" parent="VBoxContainer"] [node name="ItemsContainer" type="VBoxContainer" parent="HudInfo"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 3 size_flags_vertical = 3
theme_override_constants/separation = 0 theme_override_constants/separation = 0

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=144 format=4 uid="uid://bv451a8wgty4u"] [gd_scene load_steps=145 format=4 uid="uid://bv451a8wgty4u"]
[ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"] [ext_resource type="Script" uid="uid://doxmbokehw8ci" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
[ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"] [ext_resource type="PackedScene" uid="uid://c4pr2707hbeph" path="res://Scenes/Actors/fsm_player.tscn" id="2_ksslq"]
@ -66,6 +66,7 @@
[ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="46_0bqta"] [ext_resource type="Script" uid="uid://b5fesrd4lv8t1" path="res://Scripts/Resources/Events/EventResource.cs" id="46_0bqta"]
[ext_resource type="Script" uid="uid://ddv26x2qilprb" path="res://Scripts/Resources/Events/DialogueStartEvent.cs" id="46_i0omr"] [ext_resource type="Script" uid="uid://ddv26x2qilprb" path="res://Scripts/Resources/Events/DialogueStartEvent.cs" id="46_i0omr"]
[ext_resource type="PackedScene" uid="uid://cqrkisw6jg24w" path="res://Scenes/Props/MainFrame1.tscn" id="46_ny2s2"] [ext_resource type="PackedScene" uid="uid://cqrkisw6jg24w" path="res://Scenes/Props/MainFrame1.tscn" id="46_ny2s2"]
[ext_resource type="Script" uid="uid://b5s5mjuk1rng5" path="res://Scripts/Resources/TimeModifier.cs" id="46_wma5c"]
[ext_resource type="PackedScene" uid="uid://cdti0hnbs3e63" path="res://Scenes/Actors/RoamingSusan.tscn" id="47_u1ve6"] [ext_resource type="PackedScene" uid="uid://cdti0hnbs3e63" path="res://Scenes/Actors/RoamingSusan.tscn" id="47_u1ve6"]
[ext_resource type="PackedScene" uid="uid://cke02i4e3bxld" path="res://Scenes/Props/MainFrame2.tscn" id="47_y5mcc"] [ext_resource type="PackedScene" uid="uid://cke02i4e3bxld" path="res://Scenes/Props/MainFrame2.tscn" id="47_y5mcc"]
[ext_resource type="PackedScene" uid="uid://b0pb078xylxy" path="res://Scenes/Interactable/Valve.tscn" id="48_8usll"] [ext_resource type="PackedScene" uid="uid://b0pb078xylxy" path="res://Scenes/Interactable/Valve.tscn" id="48_8usll"]
@ -148,7 +149,7 @@ DamageType = 0
OverrideControllable = false OverrideControllable = false
Controllable = false Controllable = false
OverrideCreationModifier = false OverrideCreationModifier = false
TimeModifiers = [] TimeModifiers = Array[ExtResource("46_wma5c")]([])
WaitForCompletion = true WaitForCompletion = true
metadata/_custom_type_script = "uid://c0ndqalsc4jve" metadata/_custom_type_script = "uid://c0ndqalsc4jve"
@ -1124,7 +1125,7 @@ position = Vector2(-2000, -736)
[node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")] [node name="ControlPad8" parent="Parallax2D/Factory Tilemaps/LevelProps" node_paths=PackedStringArray("Targets") instance=ExtResource("12_hfkf1")]
position = Vector2(-2027, -735) position = Vector2(-2027, -735)
Targets = [NodePath("../HorizontalForceField")] Targets = [NodePath("../HorizontalForceField")]
Requirements = [ExtResource("84_ma1ta")] Requirements = Array[ExtResource("6_8tdlb")]([ExtResource("84_ma1ta")])
[node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")] [node name="Ammo6" parent="Parallax2D/Factory Tilemaps/LevelProps" instance=ExtResource("34_17pjh")]
position = Vector2(-872, -220) position = Vector2(-872, -220)

View file

@ -19,6 +19,8 @@ public partial class Dead : PlayerStateBase
[Export] [Export]
private ActorResourceProvider _motivationProvider; private ActorResourceProvider _motivationProvider;
private bool _isGameOver = false;
public override void EnterState() public override void EnterState()
{ {
_animationProvider.PlayDeathAnimation(); _animationProvider.PlayDeathAnimation();
@ -26,19 +28,21 @@ public partial class Dead : PlayerStateBase
if (_motivationProvider.CurrentResource < 100f) if (_motivationProvider.CurrentResource < 100f)
{ {
// If motivation is not enough show game over scene // If motivation is not enough show game over scene
GD.Print("Game over"); Hud.Instance.ShowGameOver();
_isGameOver = true;
} }
else else
{ {
// Else show respawn notification // Else show respawn notification
Hud.Instance.ShowGameOver(); Hud.Instance.ShowTerminated();
_isGameOver = false;
} }
} }
public override void ExitState() public override void ExitState()
{ {
// Hide game over // Hide game over
Hud.Instance.HideGameOver(); Hud.Instance.HideTerminated();
} }
public override void ProcessState(double delta) public override void ProcessState(double delta)
@ -46,7 +50,16 @@ public partial class Dead : PlayerStateBase
// wait for button // wait for button
if (_inputProvider.GetShootJustPressed()) if (_inputProvider.GetShootJustPressed())
{ {
Respawn(); if (_isGameOver)
{
// Restart Level
GlobalState.Instance.RestartLevel();
}
else
{
Respawn();
}
} }
} }

View file

@ -219,4 +219,8 @@ public partial class GlobalState : Node
DisplayServer.CursorSetCustomImage(scaled); DisplayServer.CursorSetCustomImage(scaled);
} }
public void RestartLevel()
{
GotoScene(CurrentScene.GetSceneFilePath());
}
} }

View file

@ -41,6 +41,9 @@ public partial class Hud : CanvasLayer
[Export] private LabelSettings _labelSettings; [Export] private LabelSettings _labelSettings;
[Export] private Container _gameOverPanel; [Export] private Container _gameOverPanel;
[Export] private Container _fairyTerminatedPanel;
[Export] private Container _hudInfoPanel;
[ExportGroup("Pause Menu")] [Export] [ExportGroup("Pause Menu")] [Export]
public Control PauseMenuContainer; public Control PauseMenuContainer;
@ -92,22 +95,48 @@ public partial class Hud : CanvasLayer
public void ShowGameOver() public void ShowGameOver()
{ {
_gameOverPanel.Show(); _gameOverPanel.Show();
HideHud();
_playerDead = true; _playerDead = true;
} }
public void HideGameOver() public void HideGameOver()
{ {
_gameOverPanel.Hide(); _gameOverPanel.Hide();
ShowHud();
_playerDead = false; _playerDead = false;
} }
public void ShowTerminated()
{
_fairyTerminatedPanel.Show();
HideHud();
_playerDead = true;
}
public void HideTerminated()
{
_fairyTerminatedPanel.Hide();
ShowHud();
_playerDead = false;
}
public void ShowHud()
{
_hudInfoPanel.Show();
}
public void HideHud()
{
_hudInfoPanel.Hide();
}
public void UpdateHealth(float newHealth, float maxHealth) public void UpdateHealth(float newHealth, float maxHealth)
{ {
// Hide game over if player is no longer dead // Hide game over if player is no longer dead
if (_playerDead && newHealth > 0) if (_playerDead && newHealth > 0)
{ {
_playerDead = false; _playerDead = false;
_gameOverPanel.Hide(); _fairyTerminatedPanel.Hide();
} }
_healthLabel.Text = $"{newHealth}/{maxHealth}"; _healthLabel.Text = $"{newHealth}/{maxHealth}";