| /// </summary>␍␊ |
| public SerializableDictionary CustomProperties;␍␊ |
| ␍␊ |
| private Dictionary<string, Texture2D> _texturecache;␍␊ |
| ␍␊ |
| ␍␊ |
| public Level()␍␊ |
| {␍␊ |
| Visible = true;␍␊ |
| Layers = new List<Layer>();␍␊ |
| CustomProperties = new SerializableDictionary();␍␊ |
| _texturecache = new Dictionary<string, Texture2D>();␍␊ |
| }␍␊ |
| ␍␊ |
| public Level(World world)␍␊ |
|
| Layers = new List<Layer>();␍␊ |
| CustomProperties = new SerializableDictionary();␍␊ |
| _world = world;␍␊ |
| _texturecache = new Dictionary<string, Texture2D>();␍␊ |
| }␍␊ |
| ␍␊ |
| public static Level FromFile(string filename, ContentManager cm, World world, ref Dictionary<string, Texture2D> cache)␍␊ |
| public static Level FromFile(string filename, ContentManager cm, World world)␍␊ |
| {␍␊ |
| Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();␍␊ |
| FileStream stream = System.IO.File.Open(filename, FileMode.Open);␍␊ |
| XmlSerializer serializer = new XmlSerializer(typeof(Level));␍␊ |
| Level level = (Level)serializer.Deserialize(stream);␍␊ |
|
| return level;␍␊ |
| }␍␊ |
| ␍␊ |
| public static Level FromStream(FileStream stream, ContentManager cm, World world)␍␊ |
| {␍␊ |
| Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();␍␊ |
| XmlSerializer serializer = new XmlSerializer(typeof(Level));␍␊ |
| Level level = (Level)serializer.Deserialize(stream);␍␊ |
| stream.Close();␍␊ |
| ␍␊ |
| foreach (Layer layer in level.Layers)␍␊ |
| {␍␊ |
| foreach (Item item in layer.Items)␍␊ |
| {␍␊ |
| item.CustomProperties.RestoreItemAssociations(level);␍␊ |
| item.load(cm, world, ref cache);␍␊ |
| }␍␊ |
| }␍␊ |
| ␍␊ |
| return level;␍␊ |
| }␍␊ |
| ␍␊ |
| public Item getItemByName(string name)␍␊ |
| {␍␊ |
| foreach (Layer layer in Layers)␍␊ |