Example #1
0
 /// <summary>
 /// Loads a profile data file from the persisten data path Unity uses
 /// </summary>
 void LoadProfiles()
 {
     if (File.Exists(Application.persistentDataPath + "/user_profiles.dat"))
     {
         BinaryFormatter bf   = new BinaryFormatter();
         FileStream      file = File.Open(Application.persistentDataPath + "user_profiles.dat", FileMode.Open);
         m_Profiles = (EF_Profiles)bf.Deserialize(file);
         file.Close();
     }
 }
Example #2
0
        /// <summary>
        /// Saves a profile data file to the Unity persisten Data folder
        /// </summary>
        void SaveProfiles()
        {
            if (m_Profiles != null)
            {
                BinaryFormatter bf   = new BinaryFormatter();
                FileStream      file = File.Create(Application.persistentDataPath + "/user_profiles.dat");

                EF_Profiles curProfiles = m_Profiles;
                bf.Serialize(file, curProfiles);
                file.Close();
            }
        }
Example #3
0
        /// <summary>
        /// Adds a profile to the current loacl profile data file
        /// </summary>
        /// <param name="username">Username.</param>
        /// <param name="email">Email.</param>
        public void AddProfile(string username, string email)
        {
            //Make sure our Profiles Class isnt null
            if (m_Profiles == null)
            {
                m_Profiles = new EF_Profiles();
            }

            //Make sure our username and email is not empty
            if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(email))
            {
                //Create a new profile
                EF_Profile_Data curProfile = new EF_Profile_Data();
                curProfile.username  = username;
                curProfile.email     = email;
                curProfile.created   = DateTime.Now;
                curProfile.lastLogIn = DateTime.Now;

                m_Profiles.m_Profiles.Add(curProfile);
                SaveProfiles();
                LoadProfiles();
            }
        }