Beispiel #1
0
    public void LoadList()
    {
        //if(File.Exists(Application.persistentDataPath + Path.DirectorySeparatorChar + "monsters.data"))
        //{
        Debug.Log("Loading List");

        BinaryFormatter bf = new BinaryFormatter();

        Debug.Log(bf);
        FileStream file = File.Open(Application.persistentDataPath + Path.DirectorySeparatorChar + "monsters.data", FileMode.OpenOrCreate);

        Debug.Log(file);

        MonsterData data = (MonsterData)bf.Deserialize(file);

        Debug.Log(data);
        file.Close();

        unlockedMonsters = data.unlockedMonsters;

        foreach (Monster monster in unlockedMonsters.Values)
        {
            Debug.Log("Loading " + monster.Name);
        }
        //}

        //if (File.Exists(Application.persistentDataPath + Path.DirectorySeparatorChar + "bmonsters.data"))
        //{

        Debug.Log("Loading Busy List");

        BinaryFormatter bf2 = new BinaryFormatter();

        Debug.Log(bf2);
        FileStream file2 = File.Open(Application.persistentDataPath + Path.DirectorySeparatorChar + "bmonsters.data", FileMode.OpenOrCreate);

        Debug.Log(file2);

        BusyMonstersData data2 = (BusyMonstersData)bf2.Deserialize(file2);

        Debug.Log(data2);
        file.Close();

        for (int i = 0; i < unavailableMonsters.Count; i++)
        {
            Debug.Log(unavailableMonsters[i] + " is busy");
        }

        unavailableMonsters = data2.busyMonsters;
        //}
    }
Beispiel #2
0
    public void SaveBusyList()
    {
        Debug.Log("Saving Busy List");

        BinaryFormatter bf = new BinaryFormatter();

        Debug.Log(bf);
        FileStream file = File.Open(Application.persistentDataPath + Path.DirectorySeparatorChar + "bmonsters.data", FileMode.OpenOrCreate);

        Debug.Log(file);
        BusyMonstersData data = new BusyMonstersData();

        data.busyMonsters = unavailableMonsters;
        Debug.Log(data);

        bf.Serialize(file, data);
        file.Close();
    }