Refactor GameManager and PlayerDeathComponent for improved state management and logging; update scene connections for player death handling
This commit is contained in:
@@ -9,11 +9,11 @@ namespace Mr.BrickAdventures.Autoloads;
|
|||||||
|
|
||||||
public partial class GameManager : Node
|
public partial class GameManager : Node
|
||||||
{
|
{
|
||||||
[Export] public Array<PackedScene> LevelScenes { get; set; } = new();
|
[Export] public Array<PackedScene> LevelScenes { get; set; } = [];
|
||||||
|
|
||||||
public PlayerController Player { get; set; }
|
public PlayerController Player { get; set; }
|
||||||
|
|
||||||
private List<Node> _sceneNodes = new();
|
private List<Node> _sceneNodes = [];
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Dictionary PlayerState { get; set; } = new()
|
public Dictionary PlayerState { get; set; } = new()
|
||||||
|
@@ -97,6 +97,7 @@ tile_set = ExtResource("11_0vx27")
|
|||||||
position = Vector2(215, 324)
|
position = Vector2(215, 324)
|
||||||
|
|
||||||
[connection signal="Death" from="Brick Player/HealthComponent" to="UI Layer/DeathScreen" method="OnPlayerDeath"]
|
[connection signal="Death" from="Brick Player/HealthComponent" to="UI Layer/DeathScreen" method="OnPlayerDeath"]
|
||||||
|
[connection signal="Death" from="Brick Player/HealthComponent" to="UI Layer/GameOverScreen" method="OnPlayerDeath"]
|
||||||
|
|
||||||
[editable path="Brick Player"]
|
[editable path="Brick Player"]
|
||||||
[editable path="UI Layer"]
|
[editable path="UI Layer"]
|
||||||
|
@@ -117,6 +117,7 @@ tile_set = ExtResource("10_ei558")
|
|||||||
tile_set = ExtResource("11_w7c5i")
|
tile_set = ExtResource("11_w7c5i")
|
||||||
|
|
||||||
[node name="Killzone" parent="." instance=ExtResource("13_tvdre")]
|
[node name="Killzone" parent="." instance=ExtResource("13_tvdre")]
|
||||||
|
process_mode = 4
|
||||||
position = Vector2(215, 324)
|
position = Vector2(215, 324)
|
||||||
|
|
||||||
[node name="Child" parent="." instance=ExtResource("15_vqevu")]
|
[node name="Child" parent="." instance=ExtResource("15_vqevu")]
|
||||||
@@ -137,5 +138,8 @@ Text = "LEVEL_1_TOOLTIP_2"
|
|||||||
position = Vector2(-59, -247)
|
position = Vector2(-59, -247)
|
||||||
Text = "LEVEL_1_TOOLTIP_3"
|
Text = "LEVEL_1_TOOLTIP_3"
|
||||||
|
|
||||||
|
[connection signal="Death" from="Brick Player/HealthComponent" to="UI Layer/DeathScreen" method="OnPlayerDeath"]
|
||||||
|
[connection signal="Death" from="Brick Player/HealthComponent" to="UI Layer/GameOverScreen" method="OnPlayerDeath"]
|
||||||
|
|
||||||
[editable path="Brick Player"]
|
[editable path="Brick Player"]
|
||||||
[editable path="UI Layer"]
|
[editable path="UI Layer"]
|
||||||
|
1
scripts/Resources/LevelResource.cs.uid
Normal file
1
scripts/Resources/LevelResource.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://c2h0pqhxiqswe
|
@@ -22,6 +22,13 @@ public partial class AudioSettings : Control
|
|||||||
MasterVolumeSlider.ValueChanged += OnMasterVolumeChanged;
|
MasterVolumeSlider.ValueChanged += OnMasterVolumeChanged;
|
||||||
MusicVolumeSlider.ValueChanged += OnMusicVolumeChanged;
|
MusicVolumeSlider.ValueChanged += OnMusicVolumeChanged;
|
||||||
SfxVolumeSlider.ValueChanged += OnSfxVolumeChanged;
|
SfxVolumeSlider.ValueChanged += OnSfxVolumeChanged;
|
||||||
|
|
||||||
|
LoadSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
SaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event)
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
1
scripts/UI/DeathScreen.cs.uid
Normal file
1
scripts/UI/DeathScreen.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://csprksav8mj1h
|
@@ -26,10 +26,10 @@ public partial class SettingsMenu : Control
|
|||||||
DisplaySettingsButton.Pressed += OnDisplaySettingsPressed;
|
DisplaySettingsButton.Pressed += OnDisplaySettingsPressed;
|
||||||
GameplaySettingsButton.Pressed += OnGameplaySettingsPressed;
|
GameplaySettingsButton.Pressed += OnGameplaySettingsPressed;
|
||||||
|
|
||||||
InputSettingsControl.Hide();
|
InputSettingsControl?.Hide();
|
||||||
AudioSettingsControl.Hide();
|
AudioSettingsControl?.Hide();
|
||||||
DisplaySettingsControl.Hide();
|
DisplaySettingsControl?.Hide();
|
||||||
GameplaySettingsControl.Hide();
|
GameplaySettingsControl?.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _UnhandledInput(InputEvent @event)
|
public override void _UnhandledInput(InputEvent @event)
|
||||||
|
@@ -31,6 +31,7 @@ public partial class PlayerDeathComponent : Node2D
|
|||||||
}
|
}
|
||||||
|
|
||||||
_gameManager.RemoveLives(1);
|
_gameManager.RemoveLives(1);
|
||||||
|
GD.Print("Player death, lives left: " + _gameManager.GetLives());
|
||||||
_gameManager.ResetCurrentSessionState();
|
_gameManager.ResetCurrentSessionState();
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user