summaryrefslogtreecommitdiff
path: root/Penguloon/UserdataManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Penguloon/UserdataManager.cs')
-rw-r--r--Penguloon/UserdataManager.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Penguloon/UserdataManager.cs b/Penguloon/UserdataManager.cs
new file mode 100644
index 0000000..872ab1d
--- /dev/null
+++ b/Penguloon/UserdataManager.cs
@@ -0,0 +1,50 @@
+using Android.Content;
+using Java.IO;
+using System;
+using System.Linq;
+
+
+namespace Penguloon
+{
+ public static class UserdataManager
+ {
+ public static int TotalKills { get; set; }
+ public static int TotalMoneySpent { get; set; }
+ public static int GamesPlayed { get; set; }
+
+ public static int HighestRound { get; set; }
+ public static int HighestKills { get; set; }
+
+ public static void WriteData(Context context)
+ {
+ File file = new File(context.CacheDir, "userdata.txt");
+ using (var streamWriter = new System.IO.StreamWriter(file.AbsolutePath, false))
+ {
+ streamWriter.WriteLine(TotalKills.ToString());
+ streamWriter.WriteLine(TotalMoneySpent.ToString());
+ streamWriter.WriteLine(GamesPlayed.ToString());
+ streamWriter.WriteLine(HighestRound.ToString());
+ streamWriter.WriteLine(HighestKills.ToString());
+ }
+ }
+
+ public static void ReadData(Context context)
+ {
+ File file = new File(context.CacheDir, "userdata.txt");
+
+ if (!file.Exists())
+ WriteData(context);
+
+ using (var streamReader = new System.IO.StreamReader(file.AbsolutePath, true))
+ {
+ var lines = streamReader.ReadToEnd().Split(new string[] { "\n" }, StringSplitOptions.None);
+
+ TotalKills = int.Parse(lines[0]);
+ TotalMoneySpent = int.Parse(lines[1]);
+ GamesPlayed = int.Parse(lines[2]);
+ HighestRound = int.Parse(lines[3]);
+ HighestKills = int.Parse(lines[4]);
+ }
+ }
+ }
+} \ No newline at end of file