summaryrefslogtreecommitdiff
path: root/scripts/Utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Utils')
-rw-r--r--scripts/Utils/Stats.cs52
-rw-r--r--scripts/Utils/Stats.cs.uid1
2 files changed, 53 insertions, 0 deletions
diff --git a/scripts/Utils/Stats.cs b/scripts/Utils/Stats.cs
new file mode 100644
index 0000000..d3c4aa3
--- /dev/null
+++ b/scripts/Utils/Stats.cs
@@ -0,0 +1,52 @@
+using Godot;
+using Godot.Collections;
+using TheLegendOfGustav.Utils;
+
+namespace TheLegendOfGustav.Utils;
+
+public partial class Stats : Node
+{
+ public static Stats Instance { get; set; }
+
+ public string PlayerName { get; set; }
+ public int MaxFloor { get; set; } = 0;
+
+ public int EnemiesKilled { get; set; } = 0;
+
+ public int DamageTaken { get; set; } = 0;
+
+ public override void _Ready()
+ {
+ base._Ready();
+ Instance = this;
+
+ SignalBus.Instance.DungeonFloorChanged += OnFloorChange;
+ }
+
+ public void Clear()
+ {
+ PlayerName = "";
+ MaxFloor = 0;
+ EnemiesKilled = 0;
+ DamageTaken = 0;
+ }
+
+ void OnFloorChange(int floor)
+ {
+ if (floor > MaxFloor)
+ {
+ MaxFloor = floor;
+ }
+ }
+
+ public Dictionary<string, Variant> Serialize()
+ {
+ return new()
+ {
+ {"jogador", PlayerName},
+ {"andar_mais_fundo", MaxFloor},
+ {"inimigos_mortos", EnemiesKilled},
+ {"dano_tomado", DamageTaken}
+ };
+ }
+} \ No newline at end of file
diff --git a/scripts/Utils/Stats.cs.uid b/scripts/Utils/Stats.cs.uid
new file mode 100644
index 0000000..a93778d
--- /dev/null
+++ b/scripts/Utils/Stats.cs.uid
@@ -0,0 +1 @@
+uid://eg7t08o6wpxb