From f4ed469fc9eaeebf39093fbf6601581cc10c6e2f Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 26 Oct 2025 20:02:15 -0300 Subject: feat:save AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit O vazio dentro de mim é como uma xícara de café esquecida no canto da mesa. --- scripts/Game.cs | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'scripts/Game.cs') diff --git a/scripts/Game.cs b/scripts/Game.cs index f03aa20..47102c1 100644 --- a/scripts/Game.cs +++ b/scripts/Game.cs @@ -14,6 +14,7 @@ namespace TheLegendOfGustav; /// public partial class Game : Node { + private bool initialized = false; /// /// Definição de um jogador. /// @@ -41,10 +42,12 @@ public partial class Game : Node public override void _Ready() { base._Ready(); - escapeLambda = () => EmitSignal(SignalName.MainMenuRequested); SignalBus.Instance.EscapeRequested += escapeLambda; + } + public void NewGame() + { map = GetNode("Map"); inputHandler = GetNode("InputHandler"); @@ -67,6 +70,38 @@ public partial class Game : Node turnManager = new(map); MessageLogData.Instance.AddMessage("Boa sorte!"); + initialized = true; + } + public bool LoadGame() + { + map = GetNode("Map"); + + inputHandler = GetNode("InputHandler"); + hud = GetNode("HUD"); + + // O jogador é criado pelo jogo. + Player player = new Player(Vector2I.Zero, null, playerDefinition); + Camera2D camera = GetNode("Camera2D"); + RemoveChild(camera); + + player.AddChild(camera); + + if (!map.LoadGame(player)) + { + return false; + } + + player.HealthChanged += (int hp, int maxHp) => hud.OnHealthChanged(hp, maxHp); + player.ManaChanged += hud.OnManaChanged; + player.Died += () => inputHandler.SetInputHandler(InputHandlers.GameOver); + + map.UpdateFOV(player.GridPosition); + + turnManager = new(map); + + MessageLogData.Instance.AddMessage("Boa sorte!"); + initialized = true; + return true; } public override void _Notification(int what) @@ -90,6 +125,8 @@ public partial class Game : Node { base._PhysicsProcess(delta); + if(initialized) + { Player player = map.MapData.Player; // Pegamos uma ação do usuário @@ -102,6 +139,8 @@ public partial class Game : Node // Computamos um turno. turnManager.Tick(); + + } } } -- cgit v1.2.3