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 int Level { 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]); } } public static int GetLevel(int kills) { for (int i = 1; i < 999; i++) { int killsNeeded = (int)((i * 50) * (i * 1.1)); if (kills > killsNeeded) continue; return i; } return 1; } public static int GetLevel() { for (int i = 1; i < 999; i++) { int killsNeeded = (int)((i * 50) * (i * 1.1)); if (TotalKills > killsNeeded) continue; return i; } return 1; } } }