Exemplo n.º 1
0
    public void Save()
    {
        var bf   = new BinaryFormatter();
        var file = File.Open(Application.persistentDataPath + "/StoryEventData.dat", FileMode.OpenOrCreate);

        var data = new StoryEventContainer {
            StoryEventData = StoryData
        };

        bf.Serialize(file, data);
        file.Close();
    }
Exemplo n.º 2
0
    public void ClearStoryEventData()
    {
        var bf   = new BinaryFormatter();
        var file = File.Open(Application.persistentDataPath + "/StoryEventData.dat", FileMode.Create);

        var blankStoryData = new StoryEventContainer();

        blankStoryData.StoryEventData = new bool[Enum.GetNames(typeof(StoryEvents)).Length];

        bf.Serialize(file, blankStoryData);
        file.Close();
        Load();
        Debug.Log("Story Event Data Cleared");
    }
Exemplo n.º 3
0
    public void Load()
    {
        if (File.Exists(Application.persistentDataPath + "/StoryEventData.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/StoryEventData.dat", FileMode.Open);

            StoryEventContainer data;
            try
            {
                data = (StoryEventContainer)bf.Deserialize(file);
            }
            catch
            {
                data = new StoryEventContainer();
                Debug.Log("Unable to load existing Story data set");
            }
            file.Close();

            StoryData = data.StoryEventData;
        }
    }