diff options
| author | aldrikboy <aldrikboy@gmail.com> | 2017-12-25 14:07:42 +0100 |
|---|---|---|
| committer | aldrikboy <aldrikboy@gmail.com> | 2017-12-25 14:07:42 +0100 |
| commit | 020fd61af37eaaac81d7b930be15f8c350f28b7d (patch) | |
| tree | 213e59cc8a7b60c717a0ea05159ac8967e6f5c35 /Penguloon/UserdataManager.cs | |
| parent | 3281eed3ffca3b4488335846430b231001aea753 (diff) | |
I dab everyday
Diffstat (limited to 'Penguloon/UserdataManager.cs')
| -rw-r--r-- | Penguloon/UserdataManager.cs | 50 |
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 |
