public static void save() { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/profile.sav"; FileStream stream = new FileStream(path, FileMode.Create); playerProfile profile = new playerProfile(); formatter.Serialize(stream, profile); stream.Close(); }
public static playerProfile getPlayerinfo(AccessToken token, string name, string realm, string region) { playerProfile profile = new playerProfile(); Task <Items> itemsTask = Task <Items> .Factory.StartNew(() => getPlayerItems(token, name, realm, region)); Task <float> raiderIOTask = Task <float> .Factory.StartNew(() => getRaiderIOScore( name, realm, region)); Task <List <Progress> > progressTask = Task <List <Progress> > .Factory.StartNew(() => getPlayerProgress(name, realm, region)); Task.WaitAll(itemsTask, raiderIOTask, progressTask); profile.items = itemsTask.Result; profile.raiderIOScore = raiderIOTask.Result; profile.progress = progressTask.Result; return(profile); }
public static void load() { string path = Application.persistentDataPath + "/profile.sav"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.OpenOrCreate); playerProfile profile = formatter.Deserialize(stream) as playerProfile; UserUnlockable.addMoney(profile.money); UserUnlockable.changeActiveWeapon(profile.activeWeapon); UserUnlockable.setAllWeapons(profile.weapons); UserUnlockable.setAllItems(profile.items); stream.Close(); } else { Debug.LogError("ERROR!"); } }