Пример #1
0
    public static void SavePlayer(PlayerDataOrbs data)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        FileStream      stream    = new FileStream(FilePath, FileMode.Create);

        formatter.Serialize(stream, data);
        stream.Close();
    }
Пример #2
0
    public static PlayerDataOrbs LoadPlayer()
    {
        if (File.Exists(FilePath))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(FilePath, FileMode.Open);

            PlayerDataOrbs loadedData = formatter.Deserialize(stream) as PlayerDataOrbs;
            stream.Close();

            return(loadedData);
        }
        else
        {
            SavePlayer(PlayerDataOrbs.DefaultValues);

            return(PlayerDataOrbs.DefaultValues);
        }
    }