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");
            }
        }
    }
Exemple #2
0
        public static void CreateThumbnail()
        {
            string localSlotPath = SaveSlotUtils.GetLocalSlotPath();

            if (!Directory.Exists(localSlotPath))
            {
                Directory.CreateDirectory(localSlotPath);
            }
            string        path          = localSlotPath + "thumb.png";
            RenderTexture targetTexture = LocalPlayer.MainCam.targetTexture;
            RenderTexture active        = RenderTexture.active;
            int           num           = 250;
            int           num2          = 175;
            RenderTexture renderTexture = new RenderTexture(num, num2, 24);

            LocalPlayer.MainCam.targetTexture = renderTexture;
            Texture2D texture2D = new Texture2D(num, num2, TextureFormat.RGB24, false);
            Vector3   b         = LocalPlayer.MainCamTr.forward * 3f / 4f;

            LocalPlayer.MainCamTr.position += b;
            LocalPlayer.MainCam.Render();
            LocalPlayer.MainCamTr.position -= b;
            RenderTexture.active            = renderTexture;
            texture2D.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0);
            LocalPlayer.MainCam.targetTexture = targetTexture;
            RenderTexture.active = active;
            UnityEngine.Object.Destroy(renderTexture);
            byte[] array = texture2D.EncodeToPNG();
            File.WriteAllBytes(path, array);
            CoopSteamCloud.CloudSave(SaveSlotUtils.GetCloudSlotPath() + "thumb.png", array);
        }
    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);
        }
    }
Exemple #4
0
        public static void DeleteSlot(PlayerModes mode, Slots slot)
        {
            string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, slot);

            if (Directory.Exists(localSlotPath))
            {
                SaveSlotUtils.DeleteDirectory(localSlotPath);
            }
            string[] array         = CoopSteamCloud.ListFiles();
            string   cloudSlotPath = SaveSlotUtils.GetCloudSlotPath(mode, slot);

            for (int i = 0; i < array.Length; i++)
            {
                if (array[i].StartsWith(cloudSlotPath))
                {
                    CoopSteamCloud.CloudDelete(array[i]);
                }
            }
        }
Exemple #5
0
        private void OnSerializing()
        {
            this._stats._day = Clock.Day;
            string localSlotPath = SaveSlotUtils.GetLocalSlotPath();
            string path          = localSlotPath + "info";
            string filename      = SaveSlotUtils.GetCloudSlotPath() + "info";

            if (!Directory.Exists(localSlotPath))
            {
                Directory.CreateDirectory(localSlotPath);
            }
            IFormatter formatter = new BinaryFormatter();

            byte[] array;
            using (MemoryStream memoryStream = new MemoryStream())
            {
                formatter.Serialize(memoryStream, this._stats);
                array = memoryStream.ToArray();
            }
            File.WriteAllBytes(path, array);
            CoopSteamCloud.CloudSave(filename, array);
        }
    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);
        }
    }
    public static void SyncWithCloud(string name, TitleScreen.GameSetup.PlayerModes mode, TitleScreen.GameSetup.Slots slot)
    {
        string localSlotPath = SaveSlotUtils.GetLocalSlotPath(mode, slot);
        string path          = localSlotPath + name;
        string filename      = SaveSlotUtils.GetCloudSlotPath(mode, slot) + name;
        bool   flag          = File.Exists(path);
        bool   flag2         = CoopSteamCloud.CloudFileExist(filename);
        long   num           = 0L;
        long   num2          = 0L;

        if (flag2 && flag)
        {
            num   = CoopSteamCloud.CloudTimestamp(filename);
            num2  = File.GetCreationTime(path).ToUnixTimestamp();
            flag2 = (num > num2);
            flag  = (num < num2);
        }
        if (flag2)
        {
            Debug.Log(string.Concat(new object[]
            {
                "Syncing ",
                mode,
                "/",
                slot,
                "/",
                name,
                " from cloud(",
                num,
                ") to local(",
                num2,
                ")"
            }));
            if (!Directory.Exists(localSlotPath))
            {
                Directory.CreateDirectory(localSlotPath);
            }
            File.WriteAllBytes(path, CoopSteamCloud.CloudLoad(filename));
            File.SetCreationTime(path, DateEx.UnixTimeStampToDateTime(num));
            Debug.Log(string.Concat(new object[]
            {
                "Local file (",
                name,
                ") Creation Time: ",
                File.GetCreationTime(path).ToUnixTimestamp(),
                " - ",
                num,
                " = ",
                File.GetCreationTime(path).ToUnixTimestamp() - num,
                "?"
            }));
        }
        else if (flag)
        {
            byte[] buffer = File.ReadAllBytes(path);
            bool   flag3  = CoopSteamCloud.CloudSave(filename, buffer);
            Debug.Log(string.Concat(new object[]
            {
                "Cloud file (",
                name,
                ") Creation time: ",
                CoopSteamCloud.CloudTimestamp(filename),
                " - ",
                File.GetCreationTime(path).ToUnixTimestamp(),
                " = ",
                CoopSteamCloud.CloudTimestamp(filename) - File.GetCreationTime(path).ToUnixTimestamp(),
                "?"
            }));
        }
    }
 public static bool KeyExist(string name)
 {
     return(CoopSteamCloud.CloudFileExist(name + ((!BoltNetwork.isRunning) ? string.Empty : "MP")) || !string.IsNullOrEmpty(PlayerPrefsFile.GetString(name, string.Empty, true)));
 }
Exemple #9
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;
    }
Exemple #10
0
 public static bool KeyExist(string name)
 {
     return(File.Exists(SaveSlotUtils.GetLocalSlotPath() + name) || CoopSteamCloud.CloudFileExist(name + ((!BoltNetwork.isRunning) ? string.Empty : "MP")));
 }