Example #1
0
 private void SaveToFile()
 {
     _level = new Level();
     _level.DeltaSpeed = _deltaSpeed;
     _level.Field = _field;
     _level.SizeX = _sizeX;
     _level.SizeY = _sizeY;
     _level.StartSpeed = _startSpeed;
     var formatter = new BinaryFormatter();
     using (var stream = new FileStream(Application.dataPath + "/Gamedata/Levels/" + _levelName + ".bytes",
         FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
     {
         formatter.Serialize(stream, _level);
         stream.Close();
     }
 }
Example #2
0
        private void LoadFromFIle()
        {
            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream(_file.bytes))
            {
                _level = (Level)formatter.Deserialize(stream);
                stream.Close();
            }

            _levelName = _file.name;
            _sizeX = _level.SizeX;
            _sizeY = _level.SizeY;
            _deltaSpeed = _level.DeltaSpeed;
            _startSpeed = _level.StartSpeed;
            _field = _level.Field;
            _isApplied = true;
        }