-feat: working game over menu and script.

This commit is contained in:
rsxri 2025-04-23 16:11:14 +01:00
parent e5ebf5bd5f
commit e94dbca828
4 changed files with 102 additions and 2 deletions

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=13 format=3 uid="uid://635xs5haibcn"]
[gd_scene load_steps=14 format=3 uid="uid://635xs5haibcn"]
[ext_resource type="PackedScene" uid="uid://ckh362yqjkpi0" path="res://scenes/player.tscn" id="1_1w06w"]
[ext_resource type="Script" path="res://script/game.cs" id="1_dukjm"]
[ext_resource type="PackedScene" uid="uid://b6myj160l6vf8" path="res://scenes/hud.tscn" id="2_xbhg5"]
[ext_resource type="PackedScene" uid="uid://dkyw6ve8ll885" path="res://scenes/game_over.tscn" id="2_xhmka"]
[ext_resource type="Script" path="res://script/pause_controller.cs" id="3_3v5pd"]
[ext_resource type="PackedScene" uid="uid://dnvcics1ni4pa" path="res://scenes/asteroid.tscn" id="3_b8wlr"]
[ext_resource type="PackedScene" uid="uid://bc52c4jrk6lo" path="res://scenes/upgrade_menu.tscn" id="5_p2w52"]
@ -8089,6 +8090,11 @@ offset_top = -100.0
offset_right = 200.0
offset_bottom = 100.0
[node name="GameOver" parent="UI/PauseControl" instance=ExtResource("2_xhmka")]
process_mode = 2
visible = false
layout_mode = 1
[node name="UpgradeMenu" parent="UI" node_paths=PackedStringArray("PlayerNode") instance=ExtResource("5_p2w52")]
visible = false
anchors_preset = 8

View file

@ -0,0 +1,70 @@
[gd_scene load_steps=7 format=3 uid="uid://dkyw6ve8ll885"]
[ext_resource type="FontFile" uid="uid://be6xxaq8drt5q" path="res://assets/Fonts/Kenney Pixel Square.ttf" id="1_gbk3f"]
[ext_resource type="Script" path="res://script/game_over.cs" id="1_mvgnc"]
[ext_resource type="FontFile" uid="uid://dtpvg4lmre10g" path="res://assets/Fonts/Kenney Future Narrow.ttf" id="2_65i3g"]
[sub_resource type="LabelSettings" id="LabelSettings_6mqtv"]
font = ExtResource("1_gbk3f")
font_size = 28
[sub_resource type="Theme" id="Theme_4c6ow"]
default_font = ExtResource("2_65i3g")
[sub_resource type="Theme" id="Theme_te0li"]
default_font = ExtResource("2_65i3g")
[node name="GameOver" type="CenterContainer"]
process_mode = 3
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -200.0
offset_top = -100.0
offset_right = 200.0
offset_bottom = 100.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_mvgnc")
[node name="ColorRect" type="ColorRect" parent="."]
custom_minimum_size = Vector2(400, 200)
layout_mode = 2
color = Color(0.231373, 0.219608, 0.203922, 1)
[node name="VBox" type="VBoxContainer" parent="."]
layout_mode = 2
[node name="Label" type="Label" parent="VBox"]
layout_mode = 2
text = "Game Over"
label_settings = SubResource("LabelSettings_6mqtv")
horizontal_alignment = 1
[node name="VSeparator" type="VSeparator" parent="VBox"]
visibility_layer = 0
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
[node name="HBox" type="HBoxContainer" parent="VBox"]
layout_mode = 2
[node name="Retry" type="Button" parent="VBox/HBox"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
theme = SubResource("Theme_4c6ow")
text = "Retry"
[node name="MainMenu" type="Button" parent="VBox/HBox"]
custom_minimum_size = Vector2(100, 0)
layout_mode = 2
theme = SubResource("Theme_te0li")
text = "Main Menu
"
[node name="VSeparator2" type="VSeparator" parent="VBox"]
visibility_layer = 0
custom_minimum_size = Vector2(0, 30)
layout_mode = 2

View file

@ -196,7 +196,8 @@ public partial class game : Node2D
private void OnPlayerDeath()
{
CallDeferred(nameof(SafeReloadScene)); //Reload scene to act as restart
GetTree().Paused = true;
GetNode<game_over>("UI/PauseControl/GameOver").Visible = true;
}
private void OnAIDeath(int factionInt)

View file

@ -0,0 +1,23 @@
using Godot;
using System;
public partial class game_over : CenterContainer
{
public override void _Ready()
{
GetNode<Button>("VBox/HBox/Retry").Pressed += () =>
{
GetTree().Paused = false;
Visible = false;
GetTree().ChangeSceneToFile("res://scenes/game.tscn");
};
GetNode<Button>("VBox/HBox/MainMenu").Pressed += () =>
{
GetTree().Paused = false;
GetTree().ChangeSceneToFile("res://scenes/main_menu.tscn");
};
}
}