Ejemplo n.º 1
0
    /**
     * FUNCTION NAME: OnDestroy
     * DESCRIPTION  : Saves difficulty settings for a future game session.
     * INPUTS       : None
     * OUTPUTS      : None
     **/
    public void OnDestroy()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Create(Application.persistentDataPath + "/difficulty_levels.dat");

        LPK_DifficultyData data = new LPK_DifficultyData();

        data.m_eDifficultyLevel = m_eDifficultyLevel;

        bf.Serialize(file, data);
        file.Close();
    }
Ejemplo n.º 2
0
    /**
     * FUNCTION NAME: OnEnable
     * DESCRIPTION  : Restores difficulty settings from a past game session.
     * INPUTS       : None
     * OUTPUTS      : None
     **/
    public void OnEnable()
    {
        if (File.Exists(Application.persistentDataPath + "/difficulty_levels.dat"))
        {
            BinaryFormatter    bf   = new BinaryFormatter();
            FileStream         file = File.Open(Application.persistentDataPath + "/difficulty_levels.dat", FileMode.Open);
            LPK_DifficultyData data = (LPK_DifficultyData)bf.Deserialize(file);
            file.Close();

            m_eDifficultyLevel = data.m_eDifficultyLevel;
        }
    }