示例#1
0
        public static TmxMap LoadFromFile(string tmxPath)
        {
            // Refresh uniqueId counter
            TmxMap.NextUniqueId = 0;

            string fullTmxPath = Path.GetFullPath(tmxPath);

            using (ChDir chdir = new ChDir(fullTmxPath))
            {
                TmxMap    tmxMap = new TmxMap();
                XDocument doc    = tmxMap.LoadDocument(fullTmxPath);

                tmxMap.Name = Path.GetFileNameWithoutExtension(fullTmxPath);
                tmxMap.ParseMap(doc);

                // We're done reading and parsing the tmx file
                Program.WriteLine("Map details: {0}", tmxMap.ToString());
                Program.WriteSuccess("Finished parsing file: {0}", fullTmxPath);

                // Let listeners know of our success
                if (TmxMap.OnReadTmxFileCompleted != null)
                {
                    TmxMap.OnReadTmxFileCompleted(tmxMap);
                }

                return(tmxMap);
            }
        }
示例#2
0
        public static TmxMap LoadFromFile(string tmxPath)
        {
            // Refresh uniqueId counter
            TmxMap.NextUniqueId = 0;

            string fullTmxPath = Path.GetFullPath(tmxPath);
            using (ChDir chdir = new ChDir(fullTmxPath))
            {
                TmxMap tmxMap = new TmxMap();
                XDocument doc = tmxMap.LoadDocument(fullTmxPath);

                tmxMap.Name = Path.GetFileNameWithoutExtension(fullTmxPath);
                tmxMap.ParseMap(doc);

                // We're done reading and parsing the tmx file
                Program.WriteLine("Map details: {0}", tmxMap.ToString());
                Program.WriteSuccess("Finished parsing file: {0}", fullTmxPath);

                // Let listeners know of our success
                if (TmxMap.OnReadTmxFileCompleted != null)
                {
                    TmxMap.OnReadTmxFileCompleted(tmxMap);
                }

                return tmxMap;
            }
        }
示例#3
0
 private static void ParseTilesetSource(string tsxSource, TsxTileset tileset)
 {
     tileset.Source = Path.GetFullPath(tsxSource);
     if (File.Exists(tileset.Source))
     {
         using (new ChDir(tileset.Source))
         {
             ParseTilesetXml(TmxMap.LoadDocument(tileset.Source).Root, tileset);
         }
     }
     else
     {
         Logger.WriteError("Tileset file does not exist: {0}", tileset.Source);
     }
 }
示例#4
0
        public static TmxMap LoadFromFile(string tmxPath)
        {
            string fullTmxPath = Path.GetFullPath(tmxPath);
            using (ChDir chdir = new ChDir(fullTmxPath))
            {
                TmxMap tmxMap = new TmxMap();
                XDocument doc = tmxMap.LoadDocument(fullTmxPath);

                tmxMap.Name = Path.GetFileNameWithoutExtension(fullTmxPath);
                tmxMap.ParseMapXml(doc);

                // We're done reading and parsing the tmx file
                Logger.WriteLine("Map details: {0}", tmxMap.ToString());
                Logger.WriteSuccess("Parsed: {0} ", fullTmxPath);

                tmxMap.IsLoaded = true;
                return tmxMap;
            }
        }
示例#5
0
        public static TmxMap LoadFromFile(string tmxPath)
        {
            string fullTmxPath = Path.GetFullPath(tmxPath);

            using (ChDir chdir = new ChDir(fullTmxPath))
            {
                TmxMap    tmxMap = new TmxMap();
                XDocument doc    = tmxMap.LoadDocument(fullTmxPath);

                tmxMap.Name = Path.GetFileNameWithoutExtension(fullTmxPath);
                tmxMap.ParseMapXml(doc);

                // We're done reading and parsing the tmx file
                Logger.WriteInfo("Map details: {0}", tmxMap.ToString());
                Logger.WriteSuccess("Parsed: {0} ", fullTmxPath);

                tmxMap.IsLoaded = true;
                return(tmxMap);
            }
        }
示例#6
0
        public static TgxTemplateGroup FromXml(XElement xml, TmxMap map)
        {
            TgxTemplateGroup tgxTemplateGroup = new TgxTemplateGroup(map);

            tgxTemplateGroup.FirstTemplateId = TmxHelper.GetAttributeAsUInt(xml, "firsttid");
            tgxTemplateGroup.Source          = Path.GetFullPath(TmxHelper.GetAttributeAsString(xml, "source"));
            if (File.Exists(tgxTemplateGroup.Source))
            {
                using (new ChDir(tgxTemplateGroup.Source))
                {
                    XDocument xDocument = TmxMap.LoadDocument(tgxTemplateGroup.Source);
                    tgxTemplateGroup.ParseTemplateGroupXml(xDocument.Root);
                }
            }
            else
            {
                Logger.WriteError("Template group file does not exist: {0}", tgxTemplateGroup.Source);
            }
            tgxTemplateGroup.Templates.ForEach(delegate(TgxTemplate t)
            {
                map.Templates.Add(t.GlobalId, t);
            });
            return(tgxTemplateGroup);
        }