コード例 #1
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    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 NAAUpdateSaveSlot()
 {
     noAutoAggressionSaveSlot = noAutoAggressionMainSavePath + SaveSlotUtils.GetLocalSlotPath().Substring(SaveSlotUtils.GetLocalSlotPath().Length - 6);
     if (debugSaveSlot)
     {
         ModAPI.Log.Write("Current SaveSlot: " + noAutoAggressionSaveSlot);
     }
 }
コード例 #3
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    public static byte[] GetBytes(string name, byte[] defaultValue, bool useSlots = true)
    {
        string path = ((!useSlots) ? SaveSlotUtils.GetUserPath() : SaveSlotUtils.GetLocalSlotPath()) + name;

        if (!File.Exists(path))
        {
            return(defaultValue);
        }
        return(File.ReadAllBytes(path));
    }
コード例 #4
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    public static string GetString(string name, string defaultValue = "", bool useSlots = true)
    {
        string path = ((!useSlots) ? SaveSlotUtils.GetUserPath() : SaveSlotUtils.GetLocalSlotPath()) + name;

        if (!File.Exists(path))
        {
            return(defaultValue);
        }
        return(File.ReadAllText(path));
    }
コード例 #5
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    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);
        }
    }
コード例 #6
0
		private IEnumerator LoadImageRoutine()
		{
			string path = SaveSlotUtils.GetLocalSlotPath(this._slot);
			string thumbnailPath = path + "thumb.png";
			if (File.Exists(thumbnailPath))
			{
				string url = "file:
				WWW www = new WWW(url);
				yield return www;
				this._texture.mainTexture = www.texture;
				this._texture.mainTexture.mipMapBias = -0.5f;
				this._texture.enabled = true;
			}
			else if (!File.Exists(path + "__RESUME__"))
			{
				this._texture.enabled = false;
			}
			yield break;
		}
コード例 #7
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    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);
        }
    }
コード例 #8
0
ファイル: PlayerPrefsFile.cs プロジェクト: ahvonenj/TheForest
    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(),
                "?"
            }));
        }
    }
コード例 #9
0
ファイル: LoadSaveSlotInfo.cs プロジェクト: K07H/The-Forest
		private void LoadStats()
		{
			string localSlotPath = SaveSlotUtils.GetLocalSlotPath(this._slot);
			string path = localSlotPath + "info";
			if (!File.Exists(localSlotPath + "__RESUME__"))
			{
				this._labelSlot.text = UiTranslationDatabase.TranslateKey("SLOT_" + this._slotNum, "Slot " + this._slotNum, false);
				if (this._labelStat)
				{
					this._labelStat.gameObject.SetActive(false);
				}
				if (this._labelDateTime)
				{
					this._labelDateTime.gameObject.SetActive(false);
				}
				if (Application.loadedLevelName.Equals("TitleScene"))
				{
					base.transform.parent.GetComponent<Collider>().enabled = false;
				}
			}
			else
			{
				base.transform.parent.GetComponent<Collider>().enabled = true;
				try
				{
					if (File.Exists(path))
					{
						GameStats.Stats gameStats = GameStats.Stats.LoadFromBytes(File.ReadAllBytes(path));
						this._labelSlot.text = UiTranslationDatabase.TranslateKey("SLOT_" + this._slotNum, "Slot " + this._slotNum, false) + UiTranslationDatabase.TranslateKey("_DAY_", ": day ", false) + gameStats._day;
						if (this._labelStat)
						{
							FieldInfo[] array = (from f in gameStats.GetType().GetFields()
							where (int)f.GetValue(gameStats) > 0
							select f).ToArray<FieldInfo>();
							if (array != null && array.Length > 0)
							{
								int num = UnityEngine.Random.Range(0, array.Length);
								string name = array[num].Name;
								string text;
								switch (name)
								{
								case "_treeCutDown":
									text = "Trees Cut Down: ";
									goto IL_4BC;
								case "_enemiesKilled":
									text = "Enemies Killed: ";
									goto IL_4BC;
								case "_rabbitKilled":
									text = "Rabbits Killed: ";
									goto IL_4BC;
								case "_lizardKilled":
									text = "Lizards Killed: ";
									goto IL_4BC;
								case "_raccoonKilled":
									text = "Raccoons Killed: ";
									goto IL_4BC;
								case "_deerKilled":
									text = "Deer Killed: ";
									goto IL_4BC;
								case "_turtleKilled":
									text = "Turtles Killed: ";
									goto IL_4BC;
								case "_birdKilled":
									text = "Birds Killed: ";
									goto IL_4BC;
								case "_cookedFood":
									text = "Cooked Food: ";
									goto IL_4BC;
								case "_burntFood":
									text = "Burnt Food: ";
									goto IL_4BC;
								case "_cancelledStructures":
									text = "Cancelled Structures: ";
									goto IL_4BC;
								case "_builtStructures":
									text = "Built Structures: ";
									goto IL_4BC;
								case "_destroyedStructures":
									text = "Destroyed Structures: ";
									goto IL_4BC;
								case "_repairedStructures":
									text = "Repaired Structures: ";
									goto IL_4BC;
								case "_edibleItemsUsed":
									text = "Edible Items Used: ";
									goto IL_4BC;
								case "_itemsCrafted":
									text = "Items Crafted: ";
									goto IL_4BC;
								case "_upgradesAdded":
									text = "Upgrades Added: ";
									goto IL_4BC;
								case "_arrowsFired":
									text = "Arrows Fired: ";
									goto IL_4BC;
								case "_litArrows":
									text = "Lit Arrows: ";
									goto IL_4BC;
								case "_litWeapons":
									text = "Lit Weapons: ";
									goto IL_4BC;
								case "_burntEnemies":
									text = "Burnt Enemies: ";
									goto IL_4BC;
								case "_explodedEnemies":
									text = "Exploded Enemies: ";
									goto IL_4BC;
								}
								text = string.Empty;
								IL_4BC:
								if (string.IsNullOrEmpty(text))
								{
									this._labelStat.gameObject.SetActive(false);
								}
								else
								{
									this._labelStat.gameObject.SetActive(true);
									this._labelStat.text = text + array[num].GetValue(gameStats);
								}
							}
							else
							{
								this._labelStat.gameObject.SetActive(false);
							}
						}
					}
					else
					{
						this._labelSlot.text = "Slot " + this._slotNum;
					}
				}
				catch (Exception exception)
				{
					Debug.LogException(exception);
				}
				UILabel labelSlot = this._labelSlot;
				labelSlot.text += "\n";
				try
				{
					string path2 = localSlotPath + "difficulty";
					if (File.Exists(path2))
					{
						string text2 = File.ReadAllText(path2);
						if (text2 != null)
						{
							if (text2 == "Peaceful" || text2 == "Hard" || text2 == "HardSurvival" || text2 == "Creative" || text2 == "Normal")
							{
								string text3 = text2.ToUpper();
								UILabel labelSlot2 = this._labelSlot;
								labelSlot2.text += UiTranslationDatabase.TranslateKey(text3, text3, false);
							}
						}
					}
				}
				catch (Exception ex)
				{
				}
				if (this._labelDateTime)
				{
					this._labelDateTime.text = File.GetLastWriteTime(localSlotPath + "__RESUME__").ToString(CultureInfo.CurrentCulture.DateTimeFormat);
					this._labelDateTime.gameObject.SetActive(true);
				}
			}
		}
コード例 #10
0
ファイル: PlayerPrefsFile.cs プロジェクト: DevZhav/The-Forest
 public static bool KeyExist(string name)
 {
     return(File.Exists(SaveSlotUtils.GetLocalSlotPath() + name) || CoopSteamCloud.CloudFileExist(name + ((!BoltNetwork.isRunning) ? string.Empty : "MP")));
 }