Esempio n. 1
0
 /// <summary>
 /// The load level.
 /// </summary>
 /// <param name="filename">
 /// The file name.
 /// </param>
 public void LoadFile(string filename)
 {
     using (var fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read))
     {
         var levelSerializer = new LevelSerializer();
         this.CurrentLevel = levelSerializer.Deserialize(fileStream, this);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// The load content.
        /// </summary>
        /// <param name="levelName">
        /// The level name.
        /// </param>
        public void LoadContent(string levelName)
        {
            var serializableLevel = this.Game.Content.Load <SerializableLevel>(levelName);
            var levelSerializer   = new LevelSerializer();

            this.CurrentLevel = levelSerializer.ConvertToLevel(serializableLevel, this);
            this.background.LoadContent();
        }
Esempio n. 3
0
 /// <summary>
 /// ICloneable.Clone() implementation.
 /// </summary>
 /// <returns>
 /// Returns a deep-clone.
 /// </returns>
 public object Clone()
 {
     using (var memoryStream = new MemoryStream())
     {
         var levelSerializer = new LevelSerializer();
         levelSerializer.Serialize(memoryStream, this);
         memoryStream.Seek(0, SeekOrigin.Begin);
         return(levelSerializer.Deserialize(memoryStream, null));
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Reads an object from the current stream.
        /// </summary>
        /// <param name="input">
        /// The ContentReader used to read the object.
        /// </param>
        /// <param name="existingInstance">
        /// An existing object to read into.
        /// </param>
        /// <returns>
        /// Level instance.
        /// </returns>
        protected override SerializableLevel Read(ContentReader input, SerializableLevel existingInstance)
        {
            var levelSerializer = new LevelSerializer();

            return(levelSerializer.Deserialize(input.BaseStream));
        }