Bug fixed: UI loaded before GameManger

pull/32/head
Sascha 2024-01-23 11:14:45 +07:00
parent 9fa74f9e1c
commit e3d288251e
10 changed files with 93 additions and 20 deletions

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

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

@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=240DDE4D_002DDBD7_002D403E_002DB52D_002DF5962748425A_002Fd_003AScripts_002Ff_003APlayerShip_002Ecs/@EntryIndexedValue">ExplicitlyExcluded</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=240DDE4D_002DDBD7_002D403E_002DB52D_002DF5962748425A_002Fd_003AScripts_002Ff_003APlayerShip_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=240DDE4D_002DDBD7_002D403E_002DB52D_002DF5962748425A_002Fd_003AScripts_002Ff_003AUi_002Ecs/@EntryIndexedValue">ExplicitlyExcluded</s:String></wpf:ResourceDictionary>

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -28,8 +28,11 @@ events = [SubResource("InputEventKey_gjrl7")]
[node name="SpaceShooter" type="Node3D"]
[node name="PlayerShip" parent="." instance=ExtResource("1_njb5h")]
[node name="PlayerShip" parent="." node_paths=PackedStringArray("jet", "PlayerRb", "shots") instance=ExtResource("1_njb5h")]
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")
shots = NodePath("Shots")
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, 0, 8.8, 0)
@ -106,6 +109,11 @@ stream = ExtResource("9_rtdps")
[node name="LaserSound" type="AudioStreamPlayer3D" parent="SoundManager"]
stream = ExtResource("11_bbedd")
[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("asteroidsContainer")]
script = ExtResource("9_rsrr5")
asteroids = Array[PackedScene]([ExtResource("5_do6ba"), ExtResource("6_tqoe7"), ExtResource("7_v6ul2")])
asteroidsContainer = NodePath("../Asteroids")
[node name="Ui" type="Node2D" parent="." node_paths=PackedStringArray("labelAsteroids", "labelLevel", "labelLifes", "labelNextLevel", "labelPoints", "labelGameOver", "restartButton", "reachedPointsLabel", "healthBar")]
script = ExtResource("15_xl7yx")
labelAsteroids = NodePath("VBoxLabels/LabelAsteroids")
@ -219,8 +227,3 @@ max_value = 10.0
value = 7.0
rounded = true
show_percentage = false
[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("asteroidsContainer")]
script = ExtResource("9_rsrr5")
asteroids = Array[PackedScene]([ExtResource("5_do6ba"), ExtResource("6_tqoe7"), ExtResource("7_v6ul2")])
asteroidsContainer = NodePath("../Asteroids")

@ -15,14 +15,19 @@ public partial class Ui : Node2D
[Export] private ProgressBar healthBar;
public static Ui Instance { get; private set; }
public override void _Ready() {
Instance = this;
GameManager.Instance.RefreshUi += RefreshUi;
restartButton.Pressed += RestartButtonOnPressed;
labelGameOver.Visible = GameManager.Instance.GameOver;
restartButton.Visible = GameManager.Instance.GameOver;
reachedPointsLabel.Visible = GameManager.Instance.GameOver;
RefreshUi(this, EventArgs.Empty);
if (GameManager.Instance is null)
GD.PrintErr("No GameManager found!");
else {
GameManager.Instance.RefreshUi += RefreshUi;
restartButton.Pressed += RestartButtonOnPressed;
labelGameOver.Visible = GameManager.Instance.GameOver;
restartButton.Visible = GameManager.Instance.GameOver;
reachedPointsLabel.Visible = GameManager.Instance.GameOver;
RefreshUi(this, EventArgs.Empty);
}
}
private void RefreshUi(object sender, EventArgs e) {
@ -44,7 +49,5 @@ public partial class Ui : Node2D
private void RestartButtonOnPressed() => GetTree().ReloadCurrentScene();
public void ShowMessage(string message) {
GD.Print(message);
}
public void ShowMessage(string message) => GD.Print(message);
}

@ -40,3 +40,69 @@ rm -rf \"{temp_dir}\""
dotnet/include_scripts_content=false
dotnet/include_debug_symbols=true
dotnet/embed_build_outputs=false
[preset.1]
name="Windows Desktop"
platform="Windows Desktop"
runnable=true
dedicated_server=false
custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path=""
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
encrypt_directory=false
[preset.1.options]
custom_template/debug=""
custom_template/release=""
debug/export_console_wrapper=1
binary_format/embed_pck=false
texture_format/bptc=true
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
binary_format/architecture="x86_64"
codesign/enable=false
codesign/timestamp=true
codesign/timestamp_server_url=""
codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PackedStringArray()
application/modify_resources=true
application/icon=""
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version=""
application/product_version=""
application/company_name=""
application/product_name=""
application/file_description=""
application/copyright=""
application/trademarks=""
application/export_angle=0
ssh_remote_deploy/enabled=false
ssh_remote_deploy/host="user@host_ip"
ssh_remote_deploy/port="22"
ssh_remote_deploy/extra_args_ssh=""
ssh_remote_deploy/extra_args_scp=""
ssh_remote_deploy/run_script="Expand-Archive -LiteralPath '{temp_dir}\\{archive_name}' -DestinationPath '{temp_dir}'
$action = New-ScheduledTaskAction -Execute '{temp_dir}\\{exe_name}' -Argument '{cmd_args}'
$trigger = New-ScheduledTaskTrigger -Once -At 00:00
$settings = New-ScheduledTaskSettingsSet
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings
Register-ScheduledTask godot_remote_debug -InputObject $task -Force:$true
Start-ScheduledTask -TaskName godot_remote_debug
while (Get-ScheduledTask -TaskName godot_remote_debug | ? State -eq running) { Start-Sleep -Milliseconds 100 }
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue"
ssh_remote_deploy/cleanup_script="Stop-ScheduledTask -TaskName godot_remote_debug -ErrorAction:SilentlyContinue
Unregister-ScheduledTask -TaskName godot_remote_debug -Confirm:$false -ErrorAction:SilentlyContinue
Remove-Item -Recurse -Force '{temp_dir}'"
dotnet/include_scripts_content=false
dotnet/include_debug_symbols=true
dotnet/embed_build_outputs=false

@ -13,7 +13,7 @@ config_version=5
config/name="Space Shooter"
config/version="0.1"
run/main_scene="res://Scenes/SpaceShooter.tscn"
config/features=PackedStringArray("4.3", "C#", "Forward Plus")
config/features=PackedStringArray("4.3", "C#")
boot_splash/image="res://Images/GodotSplashScreen.png"
config/icon="res://Images/Space-Shooter.png"