Esempio n. 1
0
        public static Scene LoadFrom(GameResourceManager gameResourceManager, string path)
        {
            var document = XDocument.Load(path);

            var sceneElement = document.Element("Scene");
            var scene = new Scene(sceneElement.Attribute("name").Value);

            foreach (var layerElement in sceneElement.Elements())
            {
                switch (layerElement.Name.ToString())
                {
                    case "ImageLayer":
                        scene.Add(ImageXmlRepository.ImageLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "HexLayer":
                        scene.Add(HexXmlRepository.HexLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "TileLayer":
                        scene.Add(TileXmlRepository.TileLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "ColorLayer":
                        scene.Add(ColorXmlRepository.ColorLayerFromXml(layerElement));
                        break;
                    case "SpriteLayer":
                        scene.Add(SpriteXmlRepository.SpriteLayerFromXml(gameResourceManager, layerElement));
                        break;
                    case "DrawingLayer":
                        scene.Add(DrawingXmlRepository.DrawingLayerFromXml(layerElement));
                        break;
                }
            }

            return scene;
        }
Esempio n. 2
0
        public void Save(Scene scene, string path)
        {
            var document = new XDocument();

            document.Add(new XElement("Scene",
                new XAttribute("name", scene.Name),
                scene.Children.OfType<ILayer>().Select(XmlRepository.ToXml)));

            // TODO: Fix this
            //document.Save(path);
        }
 void IScreen.LoadContent(GameResourceManager gameResourceManager)
 {
     this.ResourceManager = gameResourceManager;
     this.Scene = this.CreateScene();
 }