summaryrefslogtreecommitdiff
path: root/scripts/Game.cs
diff options
context:
space:
mode:
authorMatheus <matheus.guedes.mg.m@gmail.com>2025-10-26 20:02:15 -0300
committerMatheus <matheus.guedes.mg.m@gmail.com>2025-10-26 20:02:15 -0300
commitf4ed469fc9eaeebf39093fbf6601581cc10c6e2f (patch)
treed8f29ae3288e950b5fb1f5251845d57949ca2ac0 /scripts/Game.cs
parent639cd8cef403e9e66bf31e7888e786effac2b292 (diff)
feat:save AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
O vazio dentro de mim é como uma xícara de café esquecida no canto da mesa.
Diffstat (limited to 'scripts/Game.cs')
-rw-r--r--scripts/Game.cs41
1 files changed, 40 insertions, 1 deletions
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;
/// </summary>
public partial class Game : Node
{
+ private bool initialized = false;
/// <summary>
/// Definição de um jogador.
/// </summary>
@@ -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.Map>("Map");
inputHandler = GetNode<InputHandler>("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.Map>("Map");
+
+ inputHandler = GetNode<InputHandler>("InputHandler");
+ hud = GetNode<Hud>("HUD");
+
+ // O jogador é criado pelo jogo.
+ Player player = new Player(Vector2I.Zero, null, playerDefinition);
+ Camera2D camera = GetNode<Camera2D>("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();
+
+ }
}
}