Better visibility of Lifes, Level and Points

pull/32/head
Sascha 2024-02-02 10:21:47 +07:00
parent b7a4e4d7d4
commit be8f6fc146
15 changed files with 290 additions and 118 deletions

@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.3.0-dev.2">
<Project Sdk="Godot.NET.Sdk/4.3.0-dev">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://5lrd2y05neel"
path="res://.godot/imported/genericItem_color_087.png-6687afb309b9ba66de3b8f9ed90efe28.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/genericItem_color_087.png"
dest_files=["res://.godot/imported/genericItem_color_087.png-6687afb309b9ba66de3b8f9ed90efe28.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://34r8nb20e6y6"
path="res://.godot/imported/genericItem_white_102.png-95f126e969936aff31870ba984f94cba.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/genericItem_white_102.png"
dest_files=["res://.godot/imported/genericItem_white_102.png-95f126e969936aff31870ba984f94cba.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dru38hr1dwoq8"
path="res://.godot/imported/generic_button_circle_fill.png-2b822fd87779eace62ffa3a06cff92b1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/generic_button_circle_fill.png"
dest_files=["res://.godot/imported/generic_button_circle_fill.png-2b822fd87779eace62ffa3a06cff92b1.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dtjx04y046dsl"
path="res://.godot/imported/generic_joystick_left.png-c24ad01f9de4be994998a95880b0f98d.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Images/generic_joystick_left.png"
dest_files=["res://.godot/imported/generic_joystick_left.png-c24ad01f9de4be994998a95880b0f98d.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

@ -11,13 +11,13 @@
[sub_resource type="SphereShape3D" id="SphereShape3D_330dr"]
radius = 0.9
[node name="PlayerShip" type="Node3D" node_paths=PackedStringArray("jet", "PlayerRb", "shots")]
[node name="PlayerShip" type="Node3D" node_paths=PackedStringArray("jet", "rbPlayer", "shots")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74227e-08, 0, -1, 0, 0, 0)
script = ExtResource("1_cpbf1")
explosion = ExtResource("2_13dyf")
jet = NodePath("RigidBody3D/Jet")
laser = ExtResource("9_kbdnc")
PlayerRb = NodePath("RigidBody3D")
rbPlayer = NodePath("RigidBody3D")
shots = NodePath("Shots")
[node name="RigidBody3D" type="RigidBody3D" parent="."]

@ -1,4 +1,4 @@
[gd_scene load_steps=35 format=3 uid="uid://det8556rpxhbv"]
[gd_scene load_steps=39 format=3 uid="uid://det8556rpxhbv"]
[ext_resource type="PackedScene" uid="uid://tlr55u0gn20l" path="res://Packed-Scenes/PlayerShip.tscn" id="1_njb5h"]
[ext_resource type="Texture2D" uid="uid://cg6n1hh3lj7rn" path="res://Textures/tile_nebula_green_dff.png" id="2_43vix"]
@ -17,8 +17,12 @@
[ext_resource type="Script" path="res://Scripts/InputManager.cs" id="15_uovst"]
[ext_resource type="Script" path="res://Scripts/Ui.cs" id="15_xl7yx"]
[ext_resource type="Texture2D" uid="uid://ddikd6m3t7prw" path="res://Images/generic_arrow_3.png" id="17_1t6sc"]
[ext_resource type="Texture2D" uid="uid://dtjx04y046dsl" path="res://Images/generic_joystick_left.png" id="17_q54dq"]
[ext_resource type="Texture2D" uid="uid://dru38hr1dwoq8" path="res://Images/generic_button_circle_fill.png" id="18_8e5pf"]
[ext_resource type="Texture2D" uid="uid://bffseflkbu88e" path="res://Images/generic_arrow_long.png" id="18_b2vca"]
[ext_resource type="Texture2D" uid="uid://5lrd2y05neel" path="res://Images/genericItem_color_087.png" id="18_rfbsj"]
[ext_resource type="Texture2D" uid="uid://c4l1soqbo0rud" path="res://Images/keyboard_arrows.png" id="19_dpw4m"]
[ext_resource type="Texture2D" uid="uid://34r8nb20e6y6" path="res://Images/genericItem_white_102.png" id="19_hyybv"]
[ext_resource type="Texture2D" uid="uid://bnh0rcsf30nrm" path="res://Images/keyboard_w.png" id="20_3aqu5"]
[ext_resource type="Texture2D" uid="uid://b3ucjch8b7rve" path="res://Images/flair_disabled_cross.png" id="21_7mvgi"]
[ext_resource type="Texture2D" uid="uid://cm7ru4t8ka3jn" path="res://Images/keyboard_a.png" id="21_of2rn"]
@ -58,11 +62,11 @@ shadow_offset = Vector2(5, 5)
[node name="SpaceShooter" type="Node3D"]
process_mode = 3
[node name="PlayerShip" parent="." node_paths=PackedStringArray("jet", "PlayerRb", "shots") instance=ExtResource("1_njb5h")]
[node name="PlayerShip" parent="." node_paths=PackedStringArray("jet", "rbPlayer", "shots") instance=ExtResource("1_njb5h")]
process_mode = 1
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74227e-08, 0, -1, 0, 0, 5)
jet = NodePath("RigidBody3D/Jet")
PlayerRb = NodePath("RigidBody3D")
rbPlayer = NodePath("RigidBody3D")
shots = NodePath("Shots")
[node name="Camera3D" type="Camera3D" parent="."]
@ -156,47 +160,99 @@ asteroidsContainer = NodePath("../Asteroids")
process_mode = 3
script = ExtResource("15_uovst")
[node name="Ui" type="Node2D" parent="." node_paths=PackedStringArray("lblLevel", "lblPoints", "lblNextLevel", "vBoxGameOver", "lblGameOver", "buttonRestart", "lblReachedPoints", "barHealth", "vBoxPause", "buttonResume", "buttonPauseRestart", "vBoxCountdown", "lblCountdown", "textAnyKey", "lblAnyKey", "butExit", "barLevel")]
[node name="Ui" type="Node2D" parent="." node_paths=PackedStringArray("lblLevel", "lblPoints", "barHealth", "barLevel", "vBoxGameOver", "lblGameOver", "butGameOverRestart", "lblReachedPoints", "butGameOverExit", "vBoxPause", "buttonResume", "buttonPauseRestart", "butPauseExit", "vBoxCountdown", "lblCountdown", "textAnyKey", "lblAnyKey")]
process_mode = 3
script = ExtResource("15_xl7yx")
lblLevel = NodePath("VBoxStats/lblLevel")
lblPoints = NodePath("VBoxStats/lblPoints")
lblNextLevel = NodePath("VBoxStats/lblNextLevel")
lblLevel = NodePath("HBoxTop/VBoxStats/lblLevel")
lblPoints = NodePath("HBoxTop/VBoxStats/lblPoints")
barHealth = NodePath("HBoxTop/VBoxBars/barHealth")
barLevel = NodePath("HBoxTop/VBoxBars/barProgress")
vBoxGameOver = NodePath("VBoxGameOver")
lblGameOver = NodePath("VBoxGameOver/lblGameOver")
buttonRestart = NodePath("VBoxGameOver/butRestart")
butGameOverRestart = NodePath("VBoxGameOver/butGameOverRestart")
lblReachedPoints = NodePath("VBoxGameOver/lblReachedPoints")
barHealth = NodePath("HBoxTop/VBoxBars/barHealth")
butGameOverExit = NodePath("VBoxGameOver/butGameOverExit")
vBoxPause = NodePath("VBoxPause")
buttonResume = NodePath("VBoxPause/ButtonResume")
buttonPauseRestart = NodePath("VBoxPause/PauseRestartButton")
buttonPauseRestart = NodePath("VBoxPause/butPauseRestart")
butPauseExit = NodePath("VBoxPause/butPauseExit")
vBoxCountdown = NodePath("VBoxCountdown")
lblCountdown = NodePath("VBoxCountdown/lblCountdown")
textAnyKey = NodePath("VBoxCountdown/textPressKey")
lblAnyKey = NodePath("VBoxCountdown/lblPressKey")
butExit = NodePath("VBoxGameOver/butExit")
barLevel = NodePath("HBoxTop/VBoxBars/barLevel")
[node name="HBoxTop" type="HBoxContainer" parent="Ui"]
offset_left = 160.0
offset_top = 25.0
offset_right = 660.0
offset_bottom = 25.0
custom_minimum_size = Vector2(700, 0)
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = 50.0
offset_top = 50.0
offset_right = 754.0
offset_bottom = 104.0
grow_horizontal = 2
[node name="VBoxIcons" type="VBoxContainer" parent="Ui/HBoxTop"]
custom_minimum_size = Vector2(100, 50)
[node name="VBoxIconsLevelPoints" type="VBoxContainer" parent="Ui/HBoxTop"]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
tooltip_text = "10 / 10"
[node name="textLife" type="TextureRect" parent="Ui/HBoxTop/VBoxIcons"]
[node name="textLevel" type="TextureRect" parent="Ui/HBoxTop/VBoxIconsLevelPoints"]
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("17_q54dq")
expand_mode = 4
[node name="textPoints" type="TextureRect" parent="Ui/HBoxTop/VBoxIconsLevelPoints"]
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("18_8e5pf")
expand_mode = 4
[node name="textLevel" type="TextureRect" parent="Ui/HBoxTop/VBoxIcons"]
[node name="VBoxStats" type="VBoxContainer" parent="Ui/HBoxTop"]
layout_mode = 2
[node name="lblLevel" type="Label" parent="Ui/HBoxTop/VBoxStats"]
layout_mode = 2
size_flags_vertical = 1
text = "1"
horizontal_alignment = 2
vertical_alignment = 1
[node name="lblPoints" type="Label" parent="Ui/HBoxTop/VBoxStats"]
layout_mode = 2
size_flags_vertical = 1
text = "0"
horizontal_alignment = 2
[node name="VBoxIconsLifeLevel" type="VBoxContainer" parent="Ui/HBoxTop"]
custom_minimum_size = Vector2(50, 50)
layout_mode = 2
tooltip_text = "10 / 10"
[node name="textLife" type="TextureRect" parent="Ui/HBoxTop/VBoxIconsLifeLevel"]
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("19_hyybv")
expand_mode = 4
[node name="textProgress" type="TextureRect" parent="Ui/HBoxTop/VBoxIconsLifeLevel"]
custom_minimum_size = Vector2(25, 25)
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("18_rfbsj")
expand_mode = 4
[node name="VBoxBars" type="VBoxContainer" parent="Ui/HBoxTop"]
custom_minimum_size = Vector2(100, 50)
layout_mode = 2
size_flags_horizontal = 3
tooltip_text = "10 / 10"
[node name="barHealth" type="ProgressBar" parent="Ui/HBoxTop/VBoxBars"]
@ -207,7 +263,7 @@ value = 10.0
rounded = true
show_percentage = false
[node name="barLevel" type="ProgressBar" parent="Ui/HBoxTop/VBoxBars"]
[node name="barProgress" type="ProgressBar" parent="Ui/HBoxTop/VBoxBars"]
layout_mode = 2
size_flags_vertical = 3
max_value = 10.0
@ -215,28 +271,37 @@ value = 10.0
rounded = true
show_percentage = false
[node name="VBoxStats" type="VBoxContainer" parent="Ui"]
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 11.0
offset_top = 1185.0
offset_right = 211.0
offset_bottom = 1265.0
grow_vertical = 0
[node name="VBoxCountdown" type="VBoxContainer" parent="Ui"]
offset_left = 326.0
offset_top = 429.0
offset_right = 492.0
offset_bottom = 797.0
size_flags_horizontal = 4
size_flags_vertical = 4
alignment = 1
[node name="lblLevel" type="Label" parent="Ui/VBoxStats"]
[node name="lblCountdown" type="Label" parent="Ui/VBoxCountdown"]
visible = false
layout_mode = 2
text = "Level: 1"
size_flags_horizontal = 4
text = "3"
label_settings = ExtResource("27_0p8jc")
horizontal_alignment = 1
vertical_alignment = 1
[node name="lblPoints" type="Label" parent="Ui/VBoxStats"]
[node name="textPressKey" type="TextureRect" parent="Ui/VBoxCountdown"]
layout_mode = 2
text = "Points: 0"
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("28_g1v6s")
stretch_mode = 2
[node name="lblNextLevel" type="Label" parent="Ui/VBoxStats"]
[node name="lblPressKey" type="Label" parent="Ui/VBoxCountdown"]
layout_mode = 2
text = "Next Level: 10
"
size_flags_horizontal = 4
text = "Press any key to start"
horizontal_alignment = 1
vertical_alignment = 1
[node name="VBoxPause" type="VBoxContainer" parent="Ui"]
anchors_preset = 8
@ -268,7 +333,7 @@ text = "Resume
"
icon = ExtResource("18_b2vca")
[node name="PauseRestartButton" type="Button" parent="Ui/VBoxPause"]
[node name="butPauseRestart" type="Button" parent="Ui/VBoxPause"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
@ -278,43 +343,16 @@ shortcut = SubResource("Shortcut_soxs4")
text = "Restart"
icon = ExtResource("17_1t6sc")
[node name="VBoxCountdown" type="VBoxContainer" parent="Ui"]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = 330.0
offset_top = 524.0
offset_right = 496.0
offset_bottom = 892.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
alignment = 1
[node name="lblCountdown" type="Label" parent="Ui/VBoxCountdown"]
layout_mode = 2
size_flags_horizontal = 4
text = "3"
label_settings = ExtResource("27_0p8jc")
horizontal_alignment = 1
vertical_alignment = 1
[node name="textPressKey" type="TextureRect" parent="Ui/VBoxCountdown"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("28_g1v6s")
stretch_mode = 2
[node name="lblPressKey" type="Label" parent="Ui/VBoxCountdown"]
[node name="butPauseExit" type="Button" parent="Ui/VBoxPause"]
process_mode = 3
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
text = "Press any key to start"
horizontal_alignment = 1
vertical_alignment = 1
size_flags_vertical = 6
button_mask = 5
shortcut = SubResource("Shortcut_soxs4")
text = "Exit"
icon = ExtResource("21_7mvgi")
[node name="VBoxGameOver" type="VBoxContainer" parent="Ui"]
process_mode = 3
@ -345,7 +383,7 @@ horizontal_alignment = 1
vertical_alignment = 1
autowrap_mode = 3
[node name="butRestart" type="Button" parent="Ui/VBoxGameOver"]
[node name="butGameOverRestart" type="Button" parent="Ui/VBoxGameOver"]
custom_minimum_size = Vector2(200, 0)
layout_mode = 2
size_flags_horizontal = 4
@ -355,7 +393,7 @@ shortcut = SubResource("Shortcut_soxs4")
text = "Restart"
icon = ExtResource("17_1t6sc")
[node name="butExit" type="Button" parent="Ui/VBoxGameOver"]
[node name="butGameOverExit" type="Button" parent="Ui/VBoxGameOver"]
process_mode = 3
custom_minimum_size = Vector2(200, 0)
layout_mode = 2

@ -3,7 +3,7 @@ using Godot;
namespace GodotspaceShooter.Scripts;
public partial class Background : Sprite3D {
[Export] private float moveVelocity = -250f;
private const float moveVelocity = -250f;
public override void _Process(double delta) {
Rect2 region = RegionRect;

@ -136,7 +136,7 @@ public partial class GameManager : Node {
}
private void NextLevel() {
Ui.Instance.ShowMessage("Next Level!");
Ui.ShowMessage("Next Level!");
Level++;
LastLevelPoints = NextLevelPoints;
NextLevelPoints = Level * 33;

@ -3,24 +3,19 @@ using Godot;
namespace GodotspaceShooter.Scripts;
public partial class PlayerShip : Node3D {
private const float jetTimerMax = 0.5f;
private const float laserTimerMax = 1f;
[Export] private CpuParticles3D cpulaser;
[Export] private PackedScene explosion;
[Export] private GpuParticles3D gpulaser;
[Export] private Node3D jet;
private float jetTimer = jetTimerMax;
[Export] private PackedScene laser;
private float laserTimer = laserTimerMax;
[Export] private RigidBody3D rbPlayer;
[Export] private Node3D shots;
[Export] private float moveVelocity = 10f;
public float MoveVelocity => moveVelocity;
[Export] private float rotationVelocity = 15f;
public float RotationVelocity => rotationVelocity;
private const float jetTimerMax = 0.5f;
private const float laserTimerMax = 1f;
private float laserTimer = laserTimerMax;
private float jetTimer = jetTimerMax;
[Export] public RigidBody3D PlayerRb;
[Export] private Node3D shots;
public float MoveVelocity { get; private set; } = 10f;
public float RotationVelocity { get; private set; } = 15f;
public Vector3 MoveDirection { get; set; }
public Vector3 RotationDirection { get; set; }
@ -36,9 +31,9 @@ public partial class PlayerShip : Node3D {
public override void _Process(double delta) {
if (Shooting)
if (laser.Instantiate() is Node3D shot) {
shot.Position = PlayerRb.Position + new Vector3(0f, 0f, 0.74f);
shot.Position = rbPlayer.Position + new Vector3(0f, 0f, 0.74f);
shots.AddChild(shot);
SoundManager.Instance.Play(SoundManager.Sound.Laser, PlayerRb.Position);
SoundManager.Instance.Play(SoundManager.Sound.Laser, rbPlayer.Position);
Shooting = false;
}
}
@ -47,7 +42,7 @@ public partial class PlayerShip : Node3D {
//Movement
if (MoveDirection != Vector3.Zero) {
jet.Visible = true;
KinematicCollision3D collision = PlayerRb.MoveAndCollide(MoveDirection * (float)delta);
KinematicCollision3D collision = rbPlayer.MoveAndCollide(MoveDirection * (float)delta);
if (collision?.GetCollider() is Node3D collider) {
Node3D parent = collider.GetParent<Node3D>();
Vector3 collisionPosition = collision.GetPosition();
@ -67,7 +62,7 @@ public partial class PlayerShip : Node3D {
}
//Rotation
PlayerRb.RotationDegrees = RotationDirection;
rbPlayer.RotationDegrees = RotationDirection;
}
public void Explode(Vector3 collisionPosition) {

@ -6,32 +6,34 @@ using Godot;
namespace GodotspaceShooter.Scripts;
public partial class Ui : Node2D
{
[Export] private Label lblLevel;
[ExportCategory("Stats")]
[Export] private Label lblLevel;
[Export] private Label lblPoints;
[Export] private Label lblNextLevel;
[Export] private ProgressBar barHealth;
[Export] private ProgressBar barLevel;
[ExportCategory("GameOver")]
[Export] private VBoxContainer vBoxGameOver;
[Export] private Label lblGameOver;
[Export] private Button buttonRestart;
[Export] private Button butGameOverRestart;
[Export] private Label lblReachedPoints;
[Export] private ProgressBar barHealth;
[Export] private Button butGameOverExit;
[ExportCategory("Pause")]
[Export] private VBoxContainer vBoxPause;
[Export] private Button buttonResume;
[Export] private Button buttonPauseRestart;
[Export] private Button butPauseExit;
[ExportCategory("Countdown")]
[Export] private VBoxContainer vBoxCountdown;
[Export] private Label lblCountdown;
[Export] private TextureRect textAnyKey;
[Export] private Label lblAnyKey;
[Export] private Button butExit;
[Export] private ProgressBar barLevel;
private const double countdownMaxTimer = 3;
private double countdownTimer = countdownMaxTimer;
private bool countdownRunning;
public static Ui Instance { get; private set; }
public override void _Ready() {
Instance = this;
if (GameManager.Instance is null)
GD.PrintErr("No GameManager found!");
else {
@ -40,17 +42,18 @@ public partial class Ui : Node2D
GameManager.Instance.OnGameOver += GameManager_GameOver;
InputManager.Instance.StartCountdown += InputManager_StartCountdown;
lblGameOver.Visible = GameManager.Instance.GameOver;
buttonRestart.Visible = GameManager.Instance.GameOver;
butGameOverRestart.Visible = GameManager.Instance.GameOver;
lblReachedPoints.Visible = GameManager.Instance.GameOver;
buttonRestart.Pressed += ButtonRestartOnPressed;
butGameOverRestart.Pressed += AllButtonRestartOnPressed;
buttonResume.Pressed += ButtonResumeOnPressed;
buttonPauseRestart.Pressed += ButtonPauseRestartOnPressed;
butExit.Pressed += ButExitOnPressed;
buttonPauseRestart.Pressed += AllButtonRestartOnPressed;
butPauseExit.Pressed += AllButExitOnPressed;
butGameOverExit.Pressed += AllButExitOnPressed;
GameManager_RefreshStats(this, EventArgs.Empty);
}
}
private void ButExitOnPressed() => GetTree().Quit();
private void AllButExitOnPressed() => GetTree().Quit();
private void GameManager_GameOver(object sender, EventArgs e) {
GD.Print($"Game Over! You have reached level {GameManager.Instance.Level} and {GameManager.Instance.Points} points!");
@ -62,6 +65,7 @@ public partial class Ui : Node2D
private void InputManager_StartCountdown(object sender, EventArgs e) {
lblAnyKey.Visible = false;
textAnyKey.Visible = false;
lblCountdown.Visible = true;
countdownRunning = true;
}
@ -69,6 +73,7 @@ public partial class Ui : Node2D
lblCountdown.Text = countdownTimer.ToString(CultureInfo.InvariantCulture);
foreach (CanvasItem canvasItem in vBoxCountdown.GetChildren().Cast<CanvasItem>()) canvasItem.Visible = true;
vBoxCountdown.Visible = true;
lblCountdown.Visible = false;
}
public override void _Process(double delta) {
@ -85,9 +90,8 @@ public partial class Ui : Node2D
}
private void GameManager_RefreshStats(object sender, EventArgs e) {
lblLevel.Text = $"Actual Level: {GameManager.Instance.Level}";
lblPoints.Text = $"Points: {GameManager.Instance.Points}";
lblNextLevel.Text = $"Next Level at: {GameManager.Instance.NextLevelPoints}";
lblLevel.Text = $"{GameManager.Instance.Level}";
lblPoints.Text = $"{GameManager.Instance.Points}";
barHealth.MaxValue = GameManager.Instance.MaxLives;
barHealth.Value = GameManager.Instance.Lives;
@ -101,12 +105,11 @@ public partial class Ui : Node2D
vBoxGameOver.Visible = GameManager.Instance.GameOver;
}
private void ButtonRestartOnPressed() => GetTree().ReloadCurrentScene();
private void ButtonResumeOnPressed() => GameManager.Instance.GamePaused = false;
private void ButtonPauseRestartOnPressed() {
private static void ButtonResumeOnPressed() => GameManager.Instance.GamePaused = false;
private void AllButtonRestartOnPressed() {
GameManager.Instance.GamePaused = false;
GetTree().ReloadCurrentScene();
}
public void ShowMessage(string message) => GD.Print(message);
public static void ShowMessage(string message) => GD.Print(message);
}