Esempio n. 1
0
    public void VerifyMainSaveFile()
    {
        OnSaveFileAccessed();

        if (ES3.FileExists("main.es3"))
        {
            Debug.Log("Main save data exists.");
        }
        else
        {
            Debug.Log("Main save data does not exist.");
        }

        if (ES3.KeyExists("mostRecentStartup", "main.es3"))
        {
            Debug.Log("Welcome back! Last play session was " + ES3.Load <System.DateTime>("mostRecentStartup", "main.es3"));
        }

        ES3.Save <System.DateTime>("mostRecentStartup", System.DateTime.Now, "main.es3");

        if (ES3.DirectoryExists(saveFilesDirectory))
        {
            foreach (var filename in ES3.GetFiles(saveFilesDirectory))
            {
                Debug.Log("Found save file: " + filename);
            }
        }
        else
        {
            Debug.Log("No save files exist.");
        }
    }
Esempio n. 2
0
 void SpawnFiles()
 {
     foreach (var filename in ES3.GetFiles(GameMaster.saveFilesDirectory))
     {
         SpawnFile(filename);
     }
 }
Esempio n. 3
0
 public void SetLoadGameButtons()
 {
     string[] fileNames = ES3.GetFiles();
     for (int i = 0; i < fileNames.Length; i++)
     {
         if (fileNames[i] != "SaveFile.es3" && fileNames[i].Contains(".es3"))
         {
             GameObject newButton = Instantiate(loadGameButton, loadGameContent);
             newButton.GetComponent <LoadButton>().LoadSaveGameToButton(ES3.Load <SaveGame>("SaveGame", fileNames[i]));
         }
     }
 }
Esempio n. 4
0
    public int LoadLegacySavesAndReturnTheNumberOfLegacySaves(int NumberOfRegularSaves)
    {
        string[] FilesInSavesDirectory = ES3.GetFiles("saves");

        // get only .tung files and parse out the extension
        List <string> saves = new List <string>();

        foreach (string file in FilesInSavesDirectory)
        {
            if (file.Substring(file.Length - 5, 5) == ".tung") // if the extension is .tung
            {
                saves.Add(file.Substring(0, file.Length - 5));
            }
        }

        // generate the actual menu
        for (int i = 0; i < saves.Count; i++)
        {
            GameObject penis = Instantiate(SavedGamePrefab, Parent);
            penis.name = saves[i];
            // penis.transform.localPosition = new Vector3(0, -10 + i * -110, 0); // old method was to set position here, broken in 2017.3. Details on why in UISaveFile

            UISaveFile v****a = penis.GetComponent <UISaveFile>();
            v****a.FileName   = saves[i];
            v****a.Title.text = saves[i];

            v****a.LegacySave = true;
            v****a.LegacyWarning.SetActive(true);

            v****a.SetPosition(i + NumberOfRegularSaves); // new method of setting position

            // to find the size of the file, we have to load an ES3File instance
            ES3File file = new ES3File("saves/" + saves[i] + ".tung");

            v****a.Info.text =
                (file.Size() / 1024).ToString() + " kb | "                      // get file size
                + ES3.GetTimestamp("saves/" + saves[i] + ".tung").ToLocalTime() // get the local time of the last time the save was modified
                .ToString();

            UISaveFiles.Add(v****a);
        }

        Debug.Log(saves.Count.ToString() + " legacy saves");
        return(saves.Count);
    }
Esempio n. 5
0
        public void OnLogin(string account)
        {
            string playerId = ES3.FileExists("Account") && ES3.KeyExists(account, "Account") ? ES3.Load <string>(account, "Account") : AddPlayer(account);

            SyncPlayerInfo(playerId);

            string dirPath = string.Format("{0}/HeroInfo", playerId);

            string[] arr = ES3.GetFiles(dirPath);
            for (int i = 0; i < arr.Length; ++i)
            {
                SyncHero(playerId, int.Parse(arr[i]));
            }

            ByteBuffer data = new ByteBuffer();

            data.writeByte(2);
            data.writeByte(PlayerService.PLAYER_LOGIN_END);
            ServiceManager.PostMessageShortEx(data);
        }
Esempio n. 6
0
        public static List <LoadSaveInfo> GetAllSaves()
        {
            List <LoadSaveInfo> saves = new List <LoadSaveInfo>();

            foreach (string save in ES3.GetFiles(""))
            {
                if (save.EndsWith("info.9n"))
                {
                    try
                    {
                        saves.Add(LoadInfo(save.Substring(0, save.Length - 7)));
                    }
                    catch (Exception e)
                    {
                        //ignore
                        Debug.LogWarning($"Can not load save {save}");
                        Debug.LogException(e);
                    }
                }
            }

            return(saves);
        }
Esempio n. 7
0
 public override void Enter()
 {
     files.Values = ES3.GetFiles(directoryPath.Value, GetSettings());
     files.SaveChanges();
 }