//Karakter és játék adatok elmentése public void SaveProfile() { FileStream stream = OpenFile(FileMode.Create); Profile_Data data = playerProfile.GetData(); try { formatter.Serialize(stream, data); } catch (SerializationException e) { Debug.Log(e); throw; } stream.Close(); if (settingsState == ProfileSettings.NewProfile) { Notification_Controller.DisplayNotification("Az új profil létrehozva!"); } else if (settingsState == ProfileSettings.Default) { Notification_Controller.DisplayNotification("A változtatások sikeresen elmentve!"); } else if (settingsState == ProfileSettings.Silent) { settingsState = ProfileSettings.Default; } }
public Player(Profile_Data data, Deck active, Deck secondary) { ChangeName(data.username); SetUniqueID(data.profileID); SetBalance(data.coinBalance); AddActiveDeck(active); AddSecondaryDeck(secondary); }
public void LoadProfile() { string path = Path.Combine(Application.persistentDataPath, fileName); mainMenuController = GameObject.Find("Menu_Controller").GetComponent <Main_Menu_Controller>(); //Ellenőrzi, hogy van-e már mentésünk if (File.Exists(path)) { FileStream stream = OpenFile(FileMode.Open); Profile_Data data = null; try { data = formatter.Deserialize(stream) as Profile_Data; } catch (SerializationException e) { Debug.Log(e); throw; } stream.Close(); //Megnézzük, hogy a betöltött adatok érvényesek-e if (data != default(Profile_Data)) { //Amennyiben igen, úgy betöltjük őket a profilba Deck active = factory.GetDeckFromList(data.activeDeck); Deck secondary = factory.GetDeckFromList(data.secondaryDeck); playerProfile = new Player(data, active, secondary); //Jelezzük, hogy megtörtént a belépés. mainMenuController.PlayerLoginStatus(true); } else { Notification_Controller.DisplayNotification("A betöltés sikertelen!"); settingsState = ProfileSettings.NewProfile; AskForName(); NewProfile(); } } //Ha nincs még mentés file else { Notification_Controller.DisplayNotification("A mentést tároló fájl nincs létrehozva!"); settingsState = ProfileSettings.NewProfile; AskForName(); } }