예제 #1
0
    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");
            }
        }
    }
예제 #2
0
    public static void DeleteKey(string name, bool useSlots = true)
    {
        string path     = ((!useSlots) ? SaveSlotUtils.GetUserPath() : SaveSlotUtils.GetLocalSlotPath()) + name;
        string filename = ((!useSlots) ? string.Empty : SaveSlotUtils.GetCloudSlotPath()) + name;
        bool   flag     = File.Exists(path);
        bool   flag2    = CoopSteamCloud.CloudFileExist(filename);

        if (flag)
        {
            File.Delete(path);
        }
        if (flag2 && CoopSteamCloud.ShouldUseCloud())
        {
            CoopSteamCloud.CloudDelete(filename);
        }
    }
예제 #3
0
    public static void SetBytes(string name, byte[] data, bool useSlots = true)
    {
        string text  = (!useSlots) ? SaveSlotUtils.GetUserPath() : SaveSlotUtils.GetLocalSlotPath();
        string text2 = text + name;

        if (!Directory.Exists(text))
        {
            Directory.CreateDirectory(text);
        }
        if (File.Exists(text2))
        {
            string text3 = text2 + "prev";
            if (File.Exists(text3))
            {
                File.Delete(text3);
            }
            File.Move(text2, text3);
        }
        File.WriteAllBytes(text2, data);
        if (CoopSteamCloud.ShouldUseCloud())
        {
            CoopSteamCloud.CloudSave(((!useSlots) ? string.Empty : SaveSlotUtils.GetCloudSlotPath()) + name, data);
        }
    }
예제 #4
0
    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;
    }