private void Get_Info() { if (File.Exists(File_Path)) { string[] Data = File.ReadAllLines(File_Path); if (Data.Length != 1) // File corrupted { Data_Manager.Set_PlayerName(string.Empty); Data_Manager.Set_PlayerHash(string.Empty); Data_Manager.Set_HighScore(0); } else { // Convert data to byte byte[] Byte_Data = System.Convert.FromBase64String(Data[0]); // Convert to string string[] Str_Data = System.Text.Encoding.UTF8.GetString(Byte_Data).Split('|'); if (Str_Data.Length != 3) // File corrupted { Data_Manager.Set_PlayerName(string.Empty); Data_Manager.Set_PlayerHash(string.Empty); Data_Manager.Set_HighScore(0); } else { Data_Manager.Set_PlayerName(Str_Data[0]); Data_Manager.Set_PlayerHash(Str_Data[1]); Data_Manager.Set_HighScore(System.Convert.ToInt32(Str_Data[2])); } } } }
public void Post_Score(string Name, int High_Score) { if (Name != Data_Manager.Get_PlayerName()) { Data_Manager.Set_PlayerName(Name); Data_Manager.Set_HighScore(High_Score); // Generate hash string Hash_Data = Generate_Hash("Your info"); Data_Manager.Set_PlayerHash(Hash_Data); } SubmitInfo Info = new SubmitInfo("Your data"); StartCoroutine(Post(Info)); }