Exemplo n.º 1
0
    public static void CreatePlayerData()
    {
        BinaryFormatter bf     = new BinaryFormatter();
        FileStream      file   = File.Open(Application.persistentDataPath + "/Player.dat", FileMode.Create);
        PlayerData      player = new PlayerData();

        bf.Serialize(file, player);
        file.Close();
        PlayerDataRef.Initialise(player.BestRecord, player.TotalPrawnsCollected, player.TotalPlayingMins, player.LevelUnlocked);
    }
Exemplo n.º 2
0
    public static void LoadPlayerData()
    {
        BinaryFormatter bf     = new BinaryFormatter();
        PlayerData      player = new PlayerData();

        try
        {
            FileStream file = File.Open(Application.persistentDataPath + "/Player.dat", FileMode.Open);
            player = (PlayerData)bf.Deserialize(file);
            PlayerDataRef.Initialise(player.BestRecord, player.TotalPrawnsCollected, player.TotalPlayingMins, player.LevelUnlocked);
            file.Close();
        }
        catch (FileNotFoundException e)
        {
            Debug.LogException(e);
        }
    }