Beispiel #1
0
    void LoadSMG()
    {
        SMGData data = SaveSystem.LoadSMG();

        fDamage       = data.fSMGDamage;
        fOverHeatRate = data.fSMGOverheat;
    }
Beispiel #2
0
    public static void SaveSMG(SMG smg)
    {
        BinaryFormatter formatter = new BinaryFormatter();                        // allows conversion to a binary format
        string          sFilePath = Application.persistentDataPath + "/SMG.sdat"; // creates a persistant path to the save file meaning it doesn't get moved around the system

        FileStream stream = new FileStream(sFilePath, FileMode.Create);           // create the save file on the system

        SMGData smgData = new SMGData(smg);                                       // get the player information defined in the PlayerData.cs script

        formatter.Serialize(stream, smgData);                                     // serialize our data into a binary format
        stream.Close();                                                           // close our stream to stop leaks
    }
Beispiel #3
0
    public static SMGData LoadSMG()
    {
        string path = Application.persistentDataPath + "/SMG.sdat";         // keeps a constant path to the save file

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();               // allows conversion to a binary format
            FileStream      stream    = new FileStream(path, FileMode.Open); // opens the save file on the system

            SMGData data = formatter.Deserialize(stream) as SMGData;         // unserializes the save data
            stream.Close();                                                  // close our data stream to stop leaks

            return(data);
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return(null);
        }
    }