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
Weapon = ExtResource("7_xkg5o")
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
ViewRange = 120.0
AlarmReactRange = 150.0

View file

@ -48,6 +48,7 @@ MaxHealth = 4.0
MovementSpeed = 40.0
Weapon = ExtResource("7_xlxdc")
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
ViewRange = 120.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="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
MovementSpeed = 38.0
Weapon = ExtResource("7_filx8")
LootDrops = []
LootDrops = Array[ExtResource("1_f3huq")]([])
MotivationReward = 4.0
PlayerDetectionRange = 90.0
ViewRange = 120.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="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
MovementSpeed = 0.0
Weapon = ExtResource("1_yap8t")
LootDrops = []
LootDrops = Array[ExtResource("1_sma76")]([])
MotivationReward = 4.0
PlayerDetectionRange = 90.0
ViewRange = 120.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="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="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="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="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"]
@ -85,24 +86,58 @@ texture_margin_bottom = 3.0
[sub_resource type="LabelSettings" id="LabelSettings_bkqle"]
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
script = ExtResource("1_m0hb0")
WeaponContainerTemplate = ExtResource("2_mattb")
ItemNotificationTemplate = ExtResource("3_mw35l")
_healthLabel = NodePath("VBoxContainer/HealthBarContainer/HealthLabel")
_healthBar = NodePath("VBoxContainer/HealthBarContainer/HealthBar")
_shieldLabel = NodePath("VBoxContainer/ShieldBarContainer/ShieldLabel")
_shieldBar = NodePath("VBoxContainer/ShieldBarContainer/ShieldBar")
_motivationLabel = NodePath("VBoxContainer/MotivationContainer/Motivationlabel")
_itemsContainer = NodePath("VBoxContainer/ItemsContainer")
_healthLabel = NodePath("HudInfo/HealthBarContainer/HealthLabel")
_healthBar = NodePath("HudInfo/HealthBarContainer/HealthBar")
_shieldLabel = NodePath("HudInfo/ShieldBarContainer/ShieldLabel")
_shieldBar = NodePath("HudInfo/ShieldBarContainer/ShieldBar")
_motivationLabel = NodePath("HudInfo/MotivationContainer/Motivationlabel")
_itemsContainer = NodePath("HudInfo/ItemsContainer")
_labelSettings = ExtResource("2_x7kl7")
_gameOverPanel = NodePath("GameOver")
_fairyTerminatedPanel = NodePath("FairyTerminated")
_hudInfoPanel = NodePath("HudInfo")
PauseMenuContainer = NodePath("PauseMenuContainer")
PauseMenuScene = ExtResource("3_hxmxt")
DebugMenuTemplate = ExtResource("4_gd1k6")
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="."]
visible = false
offset_left = -3.0
@ -125,7 +160,7 @@ horizontal_alignment = 1
[node name="TextureRect" type="TextureRect" parent="GameOver/VBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("8_3523e")
texture = ExtResource("10_s015s")
stretch_mode = 2
[node name="Label" type="Label" parent="GameOver/VBoxContainer2"]
@ -146,7 +181,7 @@ sprite_frames = SubResource("SpriteFrames_78fwv")
frame = 1
frame_progress = 0.8514
[node name="VBoxContainer" type="VBoxContainer" parent="."]
[node name="HudInfo" type="VBoxContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
@ -160,10 +195,10 @@ size_flags_horizontal = 3
size_flags_vertical = 3
theme_override_constants/separation = 0
[node name="HealthBarContainer" type="HBoxContainer" parent="VBoxContainer"]
[node name="HealthBarContainer" type="HBoxContainer" parent="HudInfo"]
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)
layout_mode = 2
size_flags_vertical = 4
@ -173,16 +208,16 @@ value = 50.0
rounded = true
show_percentage = false
[node name="HealthLabel" type="Label" parent="VBoxContainer/HealthBarContainer"]
[node name="HealthLabel" type="Label" parent="HudInfo/HealthBarContainer"]
layout_mode = 2
text = "100/100"
label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1
[node name="ShieldBarContainer" type="HBoxContainer" parent="VBoxContainer"]
[node name="ShieldBarContainer" type="HBoxContainer" parent="HudInfo"]
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)
layout_mode = 2
size_flags_vertical = 4
@ -191,27 +226,27 @@ theme_override_styles/fill = SubResource("StyleBoxTexture_5cvcb")
value = 50.0
show_percentage = false
[node name="ShieldLabel" type="Label" parent="VBoxContainer/ShieldBarContainer"]
[node name="ShieldLabel" type="Label" parent="HudInfo/ShieldBarContainer"]
layout_mode = 2
text = "100/100"
label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1
[node name="MotivationContainer" type="HBoxContainer" parent="VBoxContainer"]
[node name="MotivationContainer" type="HBoxContainer" parent="HudInfo"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/MotivationContainer"]
[node name="Label" type="Label" parent="HudInfo/MotivationContainer"]
layout_mode = 2
text = "Motivation:"
label_settings = ExtResource("2_x7kl7")
[node name="Motivationlabel" type="Label" parent="VBoxContainer/MotivationContainer"]
[node name="Motivationlabel" type="Label" parent="HudInfo/MotivationContainer"]
layout_mode = 2
text = "100%"
label_settings = ExtResource("2_x7kl7")
vertical_alignment = 1
[node name="ItemsContainer" type="VBoxContainer" parent="VBoxContainer"]
[node name="ItemsContainer" type="VBoxContainer" parent="HudInfo"]
layout_mode = 2
size_flags_vertical = 3
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="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://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="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://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"]
@ -148,7 +149,7 @@ DamageType = 0
OverrideControllable = false
Controllable = false
OverrideCreationModifier = false
TimeModifiers = []
TimeModifiers = Array[ExtResource("46_wma5c")]([])
WaitForCompletion = true
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")]
position = Vector2(-2027, -735)
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")]
position = Vector2(-872, -220)

View file

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

View file

@ -218,5 +218,9 @@ public partial class GlobalState : Node
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 Container _gameOverPanel;
[Export] private Container _fairyTerminatedPanel;
[Export] private Container _hudInfoPanel;
[ExportGroup("Pause Menu")] [Export]
public Control PauseMenuContainer;
@ -92,14 +95,40 @@ public partial class Hud : CanvasLayer
public void ShowGameOver()
{
_gameOverPanel.Show();
HideHud();
_playerDead = true;
}
public void HideGameOver()
{
_gameOverPanel.Hide();
ShowHud();
_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)
{
@ -107,7 +136,7 @@ public partial class Hud : CanvasLayer
if (_playerDead && newHealth > 0)
{
_playerDead = false;
_gameOverPanel.Hide();
_fairyTerminatedPanel.Hide();
}
_healthLabel.Text = $"{newHealth}/{maxHealth}";