Exemplo n.º 1
0
        /// <summary>
        /// Create an OgmoProject from a source .oep file.
        /// </summary>
        /// <param name="source">The path to the .oep file.</param>
        /// <param name="imagePath">The default image path to use for loading tilemaps.</param>
        public OgmoProject(string source, string imagePath = "")
        {
            if (!File.Exists(source))
            {
                throw new ArgumentException("Ogmo project file could not be found.");
            }

            if (imagePath == "")
            {
                UseAtlas = true;
            }
            ImagePath = imagePath;

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(source);

            BackgroundColor = new Color(xmlDoc["project"]["BackgroundColor"]);
            GridColor       = new Color(xmlDoc["project"]["GridColor"]);

            var xmlLayers = xmlDoc.GetElementsByTagName("LayerDefinition");

            foreach (XmlElement x in xmlLayers)
            {
                var layer = new OgmoLayer(x);
                Layers.Add(layer.Name, layer);
            }

            //I dont know if I need to do this
            var xmlEntities = xmlDoc.GetElementsByTagName("EntityDefinition");

            foreach (XmlElement x in xmlEntities)
            {
            }

            var xmlTilesets = xmlDoc.GetElementsByTagName("Tileset");

            foreach (XmlElement x in xmlTilesets)
            {
                TileMaps.Add(x["Name"].InnerText, x["FilePath"].InnerText);
            }

            //var xmlLevelValues = xmlDoc.GetElementsByTagName("ValueDefinitions");
            //dirty dirty hack because there should only be one element with that name
            //and for SOME REASON I can't just grab an XmlElement, I have to grab a NodeList and enumerate it for my element. What gives, microsoft?
            var xmlLevelValues = xmlDoc.GetElementsByTagName("LevelValueDefinitions")[0] as XmlElement;

            foreach (XmlElement x in xmlLevelValues.GetElementsByTagName("ValueDefinition"))
            {
                levelValueTypes.Add(x.Attributes["Name"].Value, x.Attributes["xsi:type"].Value);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create an OgmoProject from a source .oep file.
        /// </summary>
        /// <param name="source">The path to the .oep file.</param>
        /// <param name="imagePath">The default image path to use for loading tilemaps.</param>
        public OgmoProject(string source, string imagePath = "")
        {
            if (!File.Exists(source))
            {
                throw new ArgumentException("Ogmo project file could not be found.");
            }

            if (imagePath == "")
            {
                UseAtlas = true;
            }
            ImagePath = imagePath;

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(source);

            BackgroundColor = new Color(xmlDoc["project"]["BackgroundColor"]);
            GridColor       = new Color(xmlDoc["project"]["GridColor"]);

            var xmlLayers = xmlDoc.GetElementsByTagName("LayerDefinition");

            foreach (XmlElement x in xmlLayers)
            {
                var layer = new OgmoLayer(x);
                Layers.Add(layer.Name, layer);
            }

            //I dont know if I need to do this
            var xmlEntities = xmlDoc.GetElementsByTagName("EntityDefinition");

            foreach (XmlElement x in xmlEntities)
            {
            }

            var xmlTilesets = xmlDoc.GetElementsByTagName("Tileset");

            foreach (XmlElement x in xmlTilesets)
            {
                TileMaps.Add(x["Name"].InnerText, x["FilePath"].InnerText);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create an OgmoProject from a source .oep file.
        /// </summary>
        /// <param name="source">The path to the .oep file.</param>
        /// <param name="imagePath">The default image path to use for loading tilemaps.</param>
        public OgmoProject(string source, string imagePath = "")
        {
            if (!File.Exists(source)) throw new ArgumentException("Ogmo project file could not be found.");

            if (imagePath == "") {
                UseAtlas = true;
            }
            ImagePath = imagePath;

            var xmlDoc = new XmlDocument();
            xmlDoc.Load(source);

            BackgroundColor = new Color(xmlDoc["project"]["BackgroundColor"]);
            GridColor = new Color(xmlDoc["project"]["GridColor"]);

            var xmlLayers = xmlDoc.GetElementsByTagName("LayerDefinition");
            foreach (XmlElement x in xmlLayers) {
                var layer = new OgmoLayer(x);
                Layers.Add(layer.Name, layer);
            }

            //I dont know if I need to do this
            var xmlEntities = xmlDoc.GetElementsByTagName("EntityDefinition");
            foreach (XmlElement x in xmlEntities) {

            }

            var xmlTilesets = xmlDoc.GetElementsByTagName("Tileset");
            foreach (XmlElement x in xmlTilesets) {
                TileMaps.Add(x["Name"].InnerText, x["FilePath"].InnerText);
            }
        }