void Save()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/playerInfo.dat");

        LevelCompleteData data = new LevelCompleteData();

        data.completedLevels = new bool[completeIndicators.Length];
        for (int i = 0; i < data.completedLevels.Length; i++)
        {
            data.completedLevels [i] = false;
        }

        bf.Serialize(file, data);
        file.Close();
    }
Beispiel #2
0
    void SaveData()
    {
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            BinaryFormatter   bf   = new BinaryFormatter();
            FileStream        file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            LevelCompleteData data = (LevelCompleteData)bf.Deserialize(file);
            file.Close();

            data.completedLevels [level] = true;

            file = File.Create(Application.persistentDataPath + "/playerInfo.dat");
            bf.Serialize(file, data);
            file.Close();
        }
    }
    void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/playerInfo.dat"))
        {
            BinaryFormatter   bf   = new BinaryFormatter();
            FileStream        file = File.Open(Application.persistentDataPath + "/playerInfo.dat", FileMode.Open);
            LevelCompleteData data = (LevelCompleteData)bf.Deserialize(file);
            file.Close();

            for (int i = 0; i < completeIndicators.Length; i++)
            {
                completeIndicators [i].SetActive(data.completedLevels [i]);
            }
        }
        else
        {
            Save();
        }
    }