public static void ConvertToSlotSystem(string name, TitleScreen.GameSetup.PlayerModes mode) { string text = PlayerPrefsFile.GetPath(name); if (mode == TitleScreen.GameSetup.PlayerModes.Multiplayer) { text += "MP"; } if (File.Exists(text)) { string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, TitleScreen.GameSetup.Slots.Slot1); if (!Directory.Exists(localSlotPath)) { Directory.CreateDirectory(localSlotPath); } File.Move(text, localSlotPath + name); } if (CoopSteamCloud.ShouldUseCloud() && CoopSteamCloud.CloudFileExist(name)) { Debug.Log("Converting cloud file: '" + name + "' to slot system"); byte[] buffer = CoopSteamCloud.CloudLoad(name); CoopSteamCloud.CloudDelete(name); if (CoopSteamCloud.CloudSave(SaveSlotUtils.GetCloudSlotPath() + name, buffer)) { Debug.Log(name + " converted successfully"); } else { Debug.Log(name + " update failed"); } } }
public static void LoadHostGameGUID() { string text = PlayerPrefsFile.GetString("guid", null, true); if (string.IsNullOrEmpty(text)) { text = Guid.NewGuid().ToString(); } CoopLobby.Instance.SetGuid(text); }
private static void SaveList() { try { BinaryFormatter binaryFormatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream()) { binaryFormatter.Serialize(memoryStream, CoopKick.Instance.kickedSteamIds); PlayerPrefsFile.SetBytes("BanList", memoryStream.ToArray(), false); } } catch (Exception exception) { Debug.LogException(exception); } }
public static void SaveHostGameGUID() { if (CoopLobby.Instance != null && CoopLobby.Instance.Info != null) { PlayerPrefsFile.SetString("guid", CoopLobby.Instance.Info.Guid, true); } else { bool flag = !string.IsNullOrEmpty(CoopLobby.HostGuid); Debug.LogError("Failed to store host GUID (lobby no longer exists) fallback=" + flag); if (flag) { PlayerPrefsFile.SetString("guid", CoopLobby.HostGuid, true); } } }
private void LoadList() { byte[] bytes = PlayerPrefsFile.GetBytes("BanList", null, false); if (bytes == null || bytes.Length == 0) { this.kickedSteamIds = new List <CoopKick.KickedPlayer>(); return; } try { BinaryFormatter binaryFormatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream(bytes)) { this.kickedSteamIds = (List <CoopKick.KickedPlayer>)binaryFormatter.Deserialize(memoryStream); } } catch (Exception exception) { Debug.LogException(exception); this.kickedSteamIds = new List <CoopKick.KickedPlayer>(); } }
public CoopKick() { try { byte[] bytes = PlayerPrefsFile.GetBytes("BanList", null, false); if (bytes != null) { IFormatter formatter = new BinaryFormatter(); using (MemoryStream memoryStream = new MemoryStream(bytes)) { this.kickedSteamIds = (List <CoopKick.KickedPlayer>)formatter.Deserialize(memoryStream); } } else { this.kickedSteamIds = new List <CoopKick.KickedPlayer>(); } } catch (Exception exception) { Debug.LogException(exception); this.kickedSteamIds = new List <CoopKick.KickedPlayer>(); } }
public static bool KeyExist(string name) { return(CoopSteamCloud.CloudFileExist(name + ((!BoltNetwork.isRunning) ? string.Empty : "MP")) || !string.IsNullOrEmpty(PlayerPrefsFile.GetString(name, string.Empty, true))); }
public static void SaveGameDifficulty() { PlayerPrefsFile.SetString("difficulty", (!GameSetup.IsCreativeGame) ? GameSetup.Difficulty.ToString() : "Creative", true); }
private IEnumerator Start() { if (!CoopPeerStarter.DedicatedHost) { while (!SteamManager.Initialized || string.IsNullOrEmpty(SteamUser.GetSteamID().ToString())) { yield return(null); } } if (SteamManager.Initialized && AccountInfo.Init()) { while (!AccountInfo.InitDone) { yield return(null); } AccountInfo.Load(); } yield return(null); int playerVersion = PlayerPrefs.GetInt("CurrentVersion", this.Current); try { if (playerVersion >= this.MinVersion) { if (playerVersion < 32) { PlayerPrefsFile.ConvertToSlotSystem("__RESUME__", PlayerModes.SinglePlayer); PlayerPrefsFile.ConvertToSlotSystem("__RESUME__", PlayerModes.Multiplayer); } if (CoopSteamCloud.ShouldUseCloud()) { IEnumerator enumerator = Enum.GetValues(typeof(Slots)).GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Slots slot = (Slots)obj; PlayerPrefsFile.SyncWithCloud("__RESUME__", PlayerModes.SinglePlayer, slot); PlayerPrefsFile.SyncWithCloud("info", PlayerModes.SinglePlayer, slot); PlayerPrefsFile.SyncWithCloud("thumb.png", PlayerModes.SinglePlayer, slot); PlayerPrefsFile.SyncWithCloud("__RESUME__", PlayerModes.Multiplayer, slot); PlayerPrefsFile.SyncWithCloud("info", PlayerModes.Multiplayer, slot); PlayerPrefsFile.SyncWithCloud("thumb.png", PlayerModes.Multiplayer, slot); PlayerPrefsFile.SyncWithCloud("guid", PlayerModes.Multiplayer, slot); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } Debug.Log("Cloud Sync Done"); } else { Debug.Log("Skipped cloud sync"); } } } catch (Exception exception) { Debug.LogException(exception); } finally { PlayerPrefs.SetInt("CurrentVersion", this.Current); PlayerPrefs.Save(); } yield break; }
static LevelSerializer() { LevelSerializer.allPrefabs = new Dictionary <string, GameObject>(); LevelSerializer.IgnoreTypes = new HashSet <string>(); LevelSerializer.CustomSerializers = new Dictionary <Type, IComponentSerializer>(); LevelSerializer.PlayerName = string.Empty; LevelSerializer.SaveResumeInformation = true; LevelSerializer.SerializationMode = LevelSerializer.SerializationModes.CacheSerialization; LevelSerializer.MaxGames = 20; LevelSerializer.SavedGames = new Index <string, List <LevelSerializer.SaveEntry> >(); LevelSerializer._stopCases = new List <Type>(); LevelSerializer.createdPlugins = new List <object>(); LevelSerializer.useCompression = false; LevelSerializer.webClient = new WebClient(); LevelSerializer.Guard = new object(); LevelSerializer._collectionCount = 0; LevelSerializer.Deserialized = delegate { }; LevelSerializer.GameSaved = delegate { }; LevelSerializer.SuspendingSerialization = delegate { }; LevelSerializer.ResumingSerialization = delegate { }; LevelSerializer.StoreComponent = delegate { }; LevelSerializer.Progress = delegate { }; LevelSerializer.webClient.UploadDataCompleted += new UploadDataCompletedEventHandler(LevelSerializer.HandleWebClientUploadDataCompleted); LevelSerializer.webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(LevelSerializer.HandleWebClientUploadStringCompleted); LevelSerializer._stopCases.Add(typeof(PrefabIdentifier)); UnitySerializer.AddPrivateType(typeof(AnimationClip)); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Assembly assembly = assemblies[i]; UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { LevelSerializer.createdPlugins.Add(Activator.CreateInstance(tp)); }, assembly, typeof(SerializerPlugIn)); UnitySerializer.ScanAllTypesForAttribute(delegate(Type tp, Attribute attr) { LevelSerializer.CustomSerializers[((ComponentSerializerFor)attr).SerializesType] = (Activator.CreateInstance(tp) as IComponentSerializer); }, assembly, typeof(ComponentSerializerFor)); } LevelSerializer.AllPrefabs = Resources.FindObjectsOfTypeAll(typeof(GameObject)).Cast <GameObject>().Where(delegate(GameObject go) { PrefabIdentifier component = go.GetComponent <PrefabIdentifier>(); return(component != null && !component.IsInScene()); }).Distinct(LevelSerializer.CompareGameObjects.Instance).ToDictionary((GameObject go) => go.GetComponent <PrefabIdentifier>().ClassId, (GameObject go) => go); try { string @string = PlayerPrefsFile.GetString("_Save_Game_Data_", string.Empty, true); if (!string.IsNullOrEmpty(@string)) { try { LevelSerializer.SavedGames = UnitySerializer.Deserialize <global::Lookup <string, List <LevelSerializer.SaveEntry> > >(Convert.FromBase64String(@string)); } catch { LevelSerializer.SavedGames = null; } } if (LevelSerializer.SavedGames == null) { LevelSerializer.SavedGames = new Index <string, List <LevelSerializer.SaveEntry> >(); LevelSerializer.SaveDataToPlayerPrefs(); } } catch { LevelSerializer.SavedGames = new Index <string, List <LevelSerializer.SaveEntry> >(); } }
public static void SaveHostGameGUID() { PlayerPrefsFile.SetString("guid", CoopLobby.Instance.Info.Guid, true); }