Exemplo n.º 1
0
        public void Save(int score)
        {
            if (score > this.Score)
            {
                Debug.Log("Saving Data");

                var bf   = new BinaryFormatter();
                var file = File.Create(Application.persistentDataPath + FILE_PATH_POST);

                var data = new ScoreData(score);

                bf.Serialize(file, data);
                file.Close();
            }
        }
Exemplo n.º 2
0
        public void Load()
        {
            if (File.Exists(Application.persistentDataPath + FILE_PATH_POST))
            {
                Debug.Log("Loading Data");

                var bf   = new BinaryFormatter();
                var file = File.Open(Application.persistentDataPath + FILE_PATH_POST, FileMode.Open);

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

                file.Close();

                this.Score = data.Round;
            }
        }