Ejemplo n.º 1
0
        void _SerializeToJson()
        {
            var info  = new GameSaveInfo();
            var scene = SceneManager.GetActiveScene();

            info.lastSceneName = scene.name;
            json = JsonConvert.SerializeObject(info, Formatting.None);
        }
Ejemplo n.º 2
0
    public static void SavePlayer(Player player)
    {
        BinaryFormatter bf     = new BinaryFormatter();
        string          path   = Application.persistentDataPath + "/player.sav";
        FileStream      stream = new FileStream(path, FileMode.Create);

        GameSaveInfo data = new GameSaveInfo(player);

        bf.Serialize(stream, data);
        stream.Close();
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Event delegate for the on scene changed event.
 /// </summary>
 private static void OnSceneChanged(Scene oldScene, Scene newScene)
 {
     if (GameSaveInfoLoadQueue != null)
     {
         if (newScene.name == GameSaveInfoLoadQueue.CurrentLevelUID) // Check if the info to be loaded belongs to the newly loaded scene.
         {
             // Load all scene parts.
             Player scenePlayer = GameObject.FindGameObjectsWithTag("Player").Where(go => go.GetComponent <Player>() != null).Select(go => go.GetComponent <Player>()).FirstOrDefault();
             GameSaveInfoLoadQueue.Player.ApplyToPlayer(ref scenePlayer);
             GameSaveInfoLoadQueue = null;
         }
     }
 }
Ejemplo n.º 4
0
        public CustomGameVersion(GameSaveInfo.Game parent, DirectoryInfo location, string saves, string ignores)
            : base(parent, "Windows", null, "Custom")
        {
            DetectedLocations locs = Core.locations.interpretPath(location.FullName);
            DetectedLocationPathHolder loc = locs.getMostAccurateLocation();

            if (loc.EV == EnvironmentVariable.VirtualStore) {
                string drive = Path.GetPathRoot(loc.FullDirPath);
                string new_path = Path.Combine(drive, loc.Path);
                loc = Core.locations.interpretPath(new_path).getMostAccurateLocation();
            }

            switch (loc.EV) {
                case EnvironmentVariable.ProgramFiles:
                case EnvironmentVariable.ProgramFilesX86:
                case EnvironmentVariable.Drive:
                    loc.EV = EnvironmentVariable.InstallLocation;
                    break;
            }

            LocationPath locpath = new LocationPath(this.Locations, loc.EV, loc.Path);

            this.Locations.Paths.Add(locpath);

            FileType type = this.addFileType("Custom");

            string path, file;
            Include save;

            if (saves != null && ignores != "") {
                path = Path.GetDirectoryName(saves);
                file = Path.GetFileName(saves);
                save = type.addSave(path, file);
            } else {
                save = type.addSave(null, null);
            }

            if (ignores != null && ignores != "") {
                path = Path.GetDirectoryName(ignores);
                file = Path.GetFileName(ignores);
                Exclude except = save.addExclusion(path, file);
            }

            if (Core.settings.EmailSender != null)
                this.Contributors.Add(Core.settings.EmailSender);
            else
                this.Contributors.Add("Anonymous");
        }
Ejemplo n.º 5
0
    public static GameSaveInfo LoadPlayer()
    {
        string path = Application.persistentDataPath + "/player.sav";

        if (File.Exists(path))
        {
            BinaryFormatter bs     = new BinaryFormatter();
            FileStream      stream = new FileStream(path, FileMode.Open);

            GameSaveInfo data = bs.Deserialize(stream) as GameSaveInfo;

            stream.Close();

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in" + path);
            return(null);
        }
    }
Ejemplo n.º 6
0
 public CustomGameVersion(GameSaveInfo.Game parent, XmlElement element)
     : base(parent, element)
 {
 }
Ejemplo n.º 7
0
 protected override GameVersion createVersion(GameSaveInfo.Game parent, XmlElement element)
 {
     return new CustomGameVersion(parent, element);
 }
Ejemplo n.º 8
0
 public ProgramFinder(GameSaveInfo.Data.Programs.ProgramVersion program) {
     this.Program = program;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Loads a saved level.
 /// </summary>
 /// <param name="gsi">The game save info to load.</param>
 public static void LoadSavedLevel(GameSaveInfo gsi)
 {
     GameSaveInfoLoadQueue = gsi;
     LoadLevel(gsi.CurrentLevelUID);
 }