Example #1
0
        public static void DeletePlayer(PlayerStore playerStore)
        {
            string playerStoreFolderPath = GetPlayerStoreFolderPath();
            string playerStorePath       = GetPlayerStorePath(playerStore, playerStoreFolderPath);

            File.Delete(playerStorePath);
            Debug.Log("Deleted player " + playerStore.Name);
        }
Example #2
0
        public static void SavePlayer(PlayerStore playerStore)
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();

            string folderPath = GetPlayerStoreFolderPath();

            if (!Directory.Exists(folderPath))
            {
                Directory.CreateDirectory(folderPath);
            }

            string dataPath = GetPlayerStorePath(playerStore, folderPath);

            using (FileStream fs = File.Open(dataPath, FileMode.OpenOrCreate)) {
                binaryFormatter.Serialize(fs, playerStore);
            }
            Debug.Log("Saved player " + playerStore.Name + " to " + dataPath);
        }
Example #3
0
 private static string GetPlayerStorePath(PlayerStore playerStore, string folderPath)
 {
     return(Path.Combine(folderPath, playerStore.Name + FILE_EXTENSION));
 }