Пример #1
0
 private static void ObjectsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode1 = xmlNode.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
     {
         if ("objects".Equals(xmlNode1.Name))
         {
             for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
             {
                 if ("Obj".Equals(xmlNode2.Name))
                 {
                     XmlNamedNodeMap attributes = (XmlNamedNodeMap)xmlNode2.Attributes;
                     XmlNode         namedItem1 = attributes.GetNamedItem("Type");
                     XmlNode         namedItem2 = attributes.GetNamedItem("NeedSync");
                     string          str        = namedItem1 != null ? namedItem1.Value : "";
                     ObjModel        objModel   = new ObjModel(namedItem2 != null && bool.Parse(namedItem2.Value))
                     {
                         _id    = int.Parse(attributes.GetNamedItem("Id").Value),
                         _life  = int.Parse(attributes.GetNamedItem("Life").Value),
                         _anim1 = int.Parse(attributes.GetNamedItem("Anim1").Value)
                     };
                     if (str == "usable")
                     {
                         objModel.canBeUsed = true;
                     }
                     if (objModel._life > -1)
                     {
                         objModel.isDestroyable = true;
                     }
                     if (objModel._anim1 > (int)byte.MaxValue)
                     {
                         if (objModel._anim1 == 256)
                         {
                             objModel._ultraSYNC = 1;
                         }
                         else if (objModel._anim1 == 257)
                         {
                             objModel._ultraSYNC = 2;
                         }
                         else if (objModel._anim1 == 258)
                         {
                             objModel._ultraSYNC = 3;
                         }
                         else if (objModel._anim1 == 259)
                         {
                             objModel._ultraSYNC = 4;
                         }
                         objModel._anim1 = (int)byte.MaxValue;
                     }
                     MappingXML.AnimsXML(xmlNode2, objModel);
                     MappingXML.DEffectsXML(xmlNode2, objModel);
                     map._objects.Add(objModel);
                 }
             }
         }
     }
 }
Пример #2
0
        public static void Load()
        {
            string path = "data/maps.xml";

            if (File.Exists(path))
            {
                MappingXML.parse(path);
            }
            else
            {
                Logger.warning("[MappingXML] Não existe o arquivo: " + path, false);
            }
        }
Пример #3
0
        private static void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                if (fileStream.Length > 0L)
                {
                    try
                    {
                        xmlDocument.Load((Stream)fileStream);
                        for (XmlNode xmlNode1 = xmlDocument.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
                        {
                            if ("list".Equals(xmlNode1.Name))
                            {
                                for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                                {
                                    if ("Map".Equals(xmlNode2.Name))
                                    {
                                        XmlNamedNodeMap attributes = (XmlNamedNodeMap)xmlNode2.Attributes;
                                        MapModel        map        = new MapModel()
                                        {
                                            _id = int.Parse(attributes.GetNamedItem("Id").Value)
                                        };
                                        MappingXML.BombsXML(xmlNode2, map);
                                        MappingXML.ObjectsXML(xmlNode2, map);
                                        MappingXML._maps.Add(map);
                                    }
                                }
                            }
                        }
                    }
                    catch (XmlException ex)
                    {
                        Logger.warning(ex.ToString(), false);
                    }
                }
                fileStream.Dispose();
                fileStream.Close();
                Logger.warning("[Aviso] Loaded " + (object)MappingXML._maps.Count + " maps", false);
            }
        }