public void Load() { if (File.Exists(Application.persistentDataPath + "/playerInfo.dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open); try { GameInfo i = (GameInfo)bf.Deserialize(file); Debug.Log("Loaded \'" + Application.persistentDataPath + "/playerInfo.dat\'"); i.bonuses.Load(); bonuses = i.bonuses; GameManager.Instance.CollectionInitializedEvent(bonuses); completedLevels = i.completedLevels; lang = i.lang; } catch (Exception) { Debug.Log("Created new info. (Catched exception in Deserialize())"); Reset(); } file.Close(); } else { Debug.Log("File \'" + Application.persistentDataPath + "/playerInfo.dat\' isn't exist"); Reset(); } }
public void Reset() { bonuses = new BonusCollection(); completedLevels = 0; lang = dfLanguageCode.EN; Debug.Log("info reseted"); GameManager.Instance.CollectionInitializedEvent(bonuses); }
public GameInfo() { bonuses = new BonusCollection(); completedLevels = 0; lang = dfLanguageCode.EN; }