Esempio n. 1
0
        private void Parcours(XmlNode node, string parent)
        {
            if (node.NodeType == XmlNodeType.Element)
            {
                if (node.Attributes.Count > 0)
                {
                    XmlNamedNodeMap mapAttributes = node.Attributes;
                    XmlNode         att           = mapAttributes.GetNamedItem("name");
                    string          name          = parent + "." + (att != null ? att.Value : node.Name);
                    string          value         = mapAttributes.GetNamedItem("value").Value.ToString();

                    // Ajout dans le dictionnaire
                    configurationOptions.Add(name, value);
                }
            }

            if (node.HasChildNodes)
            {
                XmlNode nodeChild = node.FirstChild;
                while (nodeChild != null)
                {
                    if (parent == null || parent.Equals(string.Empty))
                    {
                        Parcours(nodeChild, node.Name);
                    }
                    else
                    {
                        Parcours(nodeChild, parent + "." + node.Name);
                    }
                    nodeChild = nodeChild.NextSibling;
                }
            }
        }
Esempio n. 2
0
        public NullSerial(XmlNode _node)

        {
            if (!_node.Name.Equals(NULL_ATTR))
            {
                //throw new ClassFoundException(_node.getNodeName(), NULL_ATTR);
                throw new ClassFoundException();
            }
            XmlNamedNodeMap map_   = _node.Attributes;
            XmlNode         field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                setField(field_.Value);
            }
            XmlNode className_ = map_.GetNamedItem(CLASS);

            if (className_ != null)
            {
                setClassName(className_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                setKeyOfMap(true);
            }
        }
Esempio n. 3
0
 private static void BombsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode1 = xmlNode.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
     {
         if ("BombPositions".Equals(xmlNode1.Name))
         {
             for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
             {
                 if ("Bomb".Equals(xmlNode2.Name))
                 {
                     XmlNamedNodeMap attributes   = (XmlNamedNodeMap)xmlNode2.Attributes;
                     BombPosition    bombPosition = new BombPosition()
                     {
                         X = float.Parse(attributes.GetNamedItem("X").Value),
                         Y = float.Parse(attributes.GetNamedItem("Y").Value),
                         Z = float.Parse(attributes.GetNamedItem("Z").Value)
                     };
                     bombPosition.Position = new Half3(bombPosition.X, bombPosition.Y, bombPosition.Z);
                     if ((double)bombPosition.X == 0.0 && (double)bombPosition.Y == 0.0 && (double)bombPosition.Z == 0.0)
                     {
                         bombPosition.Everywhere = true;
                     }
                     map._bombs.Add(bombPosition);
                 }
             }
         }
     }
 }
Esempio n. 4
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("mission".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml       = xmlNode2.Attributes;
                         int             id        = int.Parse(xml.GetNamedItem("id").Value);
                         int             blueOrder = int.Parse(xml.GetNamedItem("blueOrder").Value);
                         int             exp       = int.Parse(xml.GetNamedItem("exp").Value);
                         int             gold      = int.Parse(xml.GetNamedItem("gold").Value);
                         awards.Add(new MisAwards(id, blueOrder, exp, gold));
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 5
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode PrimaryNode = document.FirstChild; PrimaryNode != null; PrimaryNode = PrimaryNode.NextSibling)
         {
             if ("list".Equals(PrimaryNode.Name))
             {
                 for (XmlNode SecundaryNode = PrimaryNode.FirstChild; SecundaryNode != null; SecundaryNode = SecundaryNode.NextSibling)
                 {
                     XmlNamedNodeMap itemMap = SecundaryNode.Attributes;
                     if ("event".Equals(SecundaryNode.Name))
                     {
                         list.Add(new EventUpModel
                         {
                             startDate = int.Parse(itemMap.GetNamedItem("start_date").Value),
                             endDate   = int.Parse(itemMap.GetNamedItem("end_date").Value),
                             percentXp = int.Parse(itemMap.GetNamedItem("percent_exp").Value),
                             percentGp = int.Parse(itemMap.GetNamedItem("percent_gold").Value)
                         });
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 6
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode primaryNode = document.FirstChild; primaryNode != null; primaryNode = primaryNode.NextSibling)
         {
             if ("list".Equals(primaryNode.Name))
             {
                 for (XmlNode secundaryNode = primaryNode.FirstChild; secundaryNode != null; secundaryNode = secundaryNode.NextSibling)
                 {
                     if ("Chara".Equals(secundaryNode.Name))
                     {
                         XmlNamedNodeMap xml   = secundaryNode.Attributes;
                         CharaModel      chara = new CharaModel
                         {
                             Id   = int.Parse(xml.GetNamedItem("Id").Value),
                             Type = int.Parse(xml.GetNamedItem("Type").Value),
                             Life = int.Parse(xml.GetNamedItem("Life").Value)
                         };
                         charas.Add(chara);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 7
0
 private static void BombsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode3 = xmlNode.FirstChild; xmlNode3 != null; xmlNode3 = xmlNode3.NextSibling)
     {
         if ("BombPositions".Equals(xmlNode3.Name))
         {
             for (XmlNode xmlNode4 = xmlNode3.FirstChild; xmlNode4 != null; xmlNode4 = xmlNode4.NextSibling)
             {
                 if ("Bomb".Equals(xmlNode4.Name))
                 {
                     XmlNamedNodeMap xml4 = xmlNode4.Attributes;
                     BombPosition    bomb = new BombPosition
                     {
                         X = float.Parse(xml4.GetNamedItem("X").Value),
                         Y = float.Parse(xml4.GetNamedItem("Y").Value),
                         Z = float.Parse(xml4.GetNamedItem("Z").Value)
                     };
                     bomb.Position = new Half3(bomb.X, bomb.Y, bomb.Z);
                     if (bomb.X == 0 && bomb.Y == 0 && bomb.Z == 0)
                     {
                         bomb.Everywhere = true;
                     }
                     map.bombs.Add(bomb);
                 }
             }
         }
     }
 }
Esempio n. 8
0
        public void xmlview(string xmlPath)
        {
            xmlDoc.Load(xmlPath);
            //取根结点
            var root = xmlDoc.DocumentElement;

            //获取根节点的所有子节点列表
            childlist = root.ChildNodes;
            ListBox1.Items.Clear();
            for (int i = 0; i < childlist.Count; i++)
            //遍历xml中所有的调用函数和对应值
            {
                XmlNode         child     = childlist[i];
                XmlNamedNodeMap childattr = child.Attributes;
                string          funcvalue = childattr.GetNamedItem("function").Value.ToString();
                string          textvalue = child.InnerText.ToString();
                string          ifvalue   = childattr.GetNamedItem("if_value").Value.ToString();
                string          iffind    = childattr.GetNamedItem("if_find").Value.ToString();
                ValueList.Add((funcvalue, textvalue, ifvalue, iffind));


                if (funcvalue == "pictureclick")
                {
                    ListBox1.Items.Add("点击" + textvalue);
                }
                if (funcvalue == "IF")
                {
                    ListBox1.Items.Add(string.Format("{0}{1} 时点击 {2}", iffind, textvalue, ifvalue));
                }
            }
        }
        /// <summary>
        /// Displays a FilePicker to the user and after they select the file
        /// it is loaded and displayed on the map.
        /// </summary>
        private async void LoadGPXFile()
        {
            FileOpenPicker fileOpenPicker = new FileOpenPicker();

            fileOpenPicker.FileTypeFilter.Add(".gpx");
            StorageFile gpxFile = await fileOpenPicker.PickSingleFileAsync();

            if (gpxFile != null)
            {
                XmlDocument gpxDoc = await XmlDocument.LoadFromFileAsync(gpxFile);

                XmlNodeList pointNodes = gpxDoc.GetElementsByTagName("trkpt");

                LocationCollection gpxRoutePoints = new LocationCollection();

                foreach (IXmlNode node in pointNodes)
                {
                    XmlNamedNodeMap attributes = node.Attributes;

                    try
                    {
                        IXmlNode latitudeAttribute = attributes.GetNamedItem("lat");
                        double   latitude          = double.Parse(latitudeAttribute.InnerText);

                        IXmlNode longitudeAttribute = attributes.GetNamedItem("lon");
                        double   longitude          = double.Parse(longitudeAttribute.InnerText);

                        gpxRoutePoints.Add(new Location(latitude, longitude));
                    }
                    catch
                    {
                        // Most likely if these values don't exist in the file it is
                        // formatted incorrectly or corrupt.  In a real app we would
                        // display some kind of error message to the user.
                    }
                }

                MapPolyline route = new MapPolyline();
                route.Color     = Windows.UI.Colors.Blue;
                route.Width     = 5;
                route.Locations = gpxRoutePoints;
                mRouteLayer.Shapes.Add(route);

                Pushpin startPin = new Pushpin();
                startPin.Text = "S";
                mMapLayer.Children.Add(startPin);
                MapLayer.SetPosition(startPin, gpxRoutePoints[0]);

                Pushpin endPin = new Pushpin();
                endPin.Text = "E";
                mMapLayer.Children.Add(endPin);
                MapLayer.SetPosition(endPin, gpxRoutePoints[gpxRoutePoints.Count - 1]);

                LocationRect bestRouteView = new LocationRect(gpxRoutePoints);
                map.SetView(bestRouteView);

                mMarkerPin.Visibility = Visibility.Collapsed;
                mMapLayer.Children.Add(mMarkerPin);
            }
        }
Esempio n. 10
0
 private static void AnimsXML(XmlNode xmlNode, ObjModel obj)
 {
     for (XmlNode xmlNode5 = xmlNode.FirstChild; xmlNode5 != null; xmlNode5 = xmlNode5.NextSibling)
     {
         if ("Anims".Equals(xmlNode5.Name))
         {
             for (XmlNode xmlNode6 = xmlNode5.FirstChild; xmlNode6 != null; xmlNode6 = xmlNode6.NextSibling)
             {
                 if ("Sync".Equals(xmlNode6.Name))
                 {
                     XmlNamedNodeMap xml6 = xmlNode6.Attributes;
                     AnimModel       anim = new AnimModel
                     {
                         Id        = int.Parse(xml6.GetNamedItem("Id").Value),
                         Duration  = float.Parse(xml6.GetNamedItem("Date").Value),
                         NextAnim  = int.Parse(xml6.GetNamedItem("Next").Value),
                         OtherObj  = int.Parse(xml6.GetNamedItem("OtherOBJ").Value),
                         OtherAnim = int.Parse(xml6.GetNamedItem("OtherANIM").Value)
                     };
                     if (anim.Id == 0)
                     {
                         obj.NoInstaSync = true;
                     }
                     if (anim.Id != 255)
                     {
                         obj.UpdateId = 3;
                     }
                     obj.Anims.Add(anim);
                 }
             }
         }
     }
 }
Esempio n. 11
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("cupom".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml   = xmlNode2.Attributes;
                         CupomFlag       cupom = new CupomFlag
                         {
                             ItemId     = int.Parse(xml.GetNamedItem("item_id").Value),
                             EffectFlag = (CupomEffects)int.Parse(xml.GetNamedItem("effect_flag").Value)
                         };
                         Effects.Add(cupom);
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 12
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
         {
             if ("list".Equals(xmlNode1.Name))
             {
                 for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                 {
                     if ("rank".Equals(xmlNode2.Name))
                     {
                         XmlNamedNodeMap xml = xmlNode2.Attributes;
                         ranks.Add(new RankModel(byte.Parse(xml.GetNamedItem("id").Value),
                                                 int.Parse(xml.GetNamedItem("onNextLevel").Value), 0,
                                                 int.Parse(xml.GetNamedItem("onAllExp").Value)));
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 13
0
 private static void AnimsXML(XmlNode xmlNode, ObjModel obj)
 {
     for (XmlNode xmlNode1 = xmlNode.FirstChild; xmlNode1 != null; xmlNode1 = xmlNode1.NextSibling)
     {
         if ("Anims".Equals(xmlNode1.Name))
         {
             for (XmlNode xmlNode2 = xmlNode1.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
             {
                 if ("Anim".Equals(xmlNode2.Name))
                 {
                     XmlNamedNodeMap attributes = (XmlNamedNodeMap)xmlNode2.Attributes;
                     AnimModel       animModel  = new AnimModel()
                     {
                         _id        = int.Parse(attributes.GetNamedItem("Id").Value),
                         _duration  = float.Parse(attributes.GetNamedItem("Duration").Value),
                         _nextAnim  = int.Parse(attributes.GetNamedItem("Next").Value),
                         _otherObj  = int.Parse(attributes.GetNamedItem("OtherOBJ").Value),
                         _otherAnim = int.Parse(attributes.GetNamedItem("OtherANIM").Value)
                     };
                     if (animModel._id == 0)
                     {
                         obj._noInstaSync = true;
                     }
                     if (animModel._id != (int)byte.MaxValue)
                     {
                         obj._updateId = 3;
                     }
                     obj._anims.Add(animModel);
                 }
             }
         }
     }
 }
Esempio n. 14
0
        public void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(@"data\xml\map_region.xml");
            if (doc.DocumentElement == null)
            {
                return;
            }

            XmlNodeList nodes = doc.DocumentElement.SelectNodes("/list/map");
            int         count = 0;

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                    if ((ownerElement == null) || (node.Attributes == null) || !ownerElement.Name.EqualsIgnoreCase("map"))
                    {
                        continue;
                    }

                    XmlNamedNodeMap attrs = node.Attributes;
                    int             rY    = Convert.ToInt32(attrs.GetNamedItem("geoY").Value) - 10;
                    for (int rX = 0; rX < RegionsX; rX++)
                    {
                        Regions[rX, rY] = Convert.ToInt32(attrs.GetNamedItem($"geoX_{rX + 16}").Value);
                        count++;
                    }
                }
            }

            Log.Info($"MapRegionTable: Loaded {count} regions.");
        }
Esempio n. 15
0
        public static void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\npcs\");
            try
            {
                StatsSet set = new StatsSet();

                foreach (string i in xmlFilesArray)
                {
                    doc.Load(i);

                    XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/npc");

                    if (nodes == null)
                    {
                        continue;
                    }

                    foreach (XmlNode node in nodes)
                    {
                        XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                        if (ownerElement != null && node.Attributes != null && ownerElement.Name == "npc")
                        {
                            XmlNamedNodeMap attrs = node.Attributes;

                            int npcId      = int.Parse(attrs.GetNamedItem("id").Value);
                            int templateId = attrs.GetNamedItem("idTemplate") == null ? npcId : int.Parse(attrs.GetNamedItem("idTemplate").Value);

                            set.Set("id", npcId);
                            set.Set("idTemplate", templateId);
                            set.Set("name", attrs.GetNamedItem("name").Value);
                            set.Set("title", attrs.GetNamedItem("title").Value);

                            foreach (XmlNode innerData in node.ChildNodes)
                            {
                                if (innerData.Attributes["name"] != null && innerData.Attributes["val"] != null)
                                {
                                    string value = innerData.Attributes["val"].Value;
                                    string name  = innerData.Attributes["name"].Value;

                                    set.Set(name, value);
                                }
                            }

                            _npcs.Add(npcId, new NpcTemplate(set));
                        }
                        set.Clear();
                    }
                }

                Log.Info($"Loaded {_npcs.Count} npcs.");
            }
            catch (Exception e)
            {
                Log.Error(e, "Error parsing NPC templates: ");
            }
        }
Esempio n. 16
0
        public void TestMethod1()
        {
            //const string folderPath = @"./data/xml/classes";
            //foreach (string file in Directory.EnumerateFiles(folderPath, "*.xml"))
            //{
            //    //string contents = File.ReadAllText(file);
            //}

            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\classes\");
            foreach (string i in xmlFilesArray)
            {
                doc.Load(i);

                XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/class");

                if (nodes == null)
                {
                    continue;
                }

                foreach (XmlNode node in nodes)
                {
                    XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                    if ((ownerElement == null) || !"class".Equals(ownerElement.Name))
                    {
                        continue;
                    }

                    //ClassIds classId = (ClassIds)int.Parse(attrs.Item(0).Value);
                    StatsSet set = new StatsSet();

                    for (XmlNode cd = node.FirstChild; cd != null; cd = cd.NextSibling)
                    {
                        if ((cd.NextSibling != null) && "set".Equals(cd.NextSibling.Name) && (cd.NextSibling != null))
                        {
                            XmlNamedNodeMap attrs = cd.NextSibling.Attributes;
                            if (attrs == null)
                            {
                                continue;
                            }

                            string name  = attrs.GetNamedItem("name").Value;
                            string value = attrs.GetNamedItem("val").Value;
                            set.Set(name, value);
                        }
                        else
                        {
                            break;
                        }
                    }
                    ////PcTemplate pcTempl = new PcTemplate(classId, set);
                    ////templates.Add((int)pcTempl.ClassId, pcTempl);
                    //System.Diagnostics.Trace.WriteLine($"Added template for: {pcTempl.ClassId}");
                }
            }
        }
Esempio n. 17
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);
                 }
             }
         }
     }
 }
        public void ConvertFile(string path)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(path);

            XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/npc");

            if (nodes == null)
            {
                return;
            }

            var localNpcTemplates = new List <NpcTemplate>();

            //ConcurrentBag<string> resultCollection = new ConcurrentBag<string>();
            //ParallelLoopResult result = Parallel.ForEach(nodes, node =>
            //{
            //    resultCollection.Add(AddB(word));
            //});

            foreach (XmlNode node in nodes)
            {
                XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                if ((ownerElement != null) && (node.Attributes != null) && "npc".Equals(ownerElement.Name))
                {
                    NpcTemplate npc = new NpcTemplate();

                    XmlNamedNodeMap attrs = node.Attributes;

                    npc.NpcId      = int.Parse(attrs.GetNamedItem("id").Value);
                    npc.TemplateId = attrs.GetNamedItem("idTemplate") == null ? npc.NpcId : int.Parse(attrs.GetNamedItem("idTemplate").Value);
                    npc.Name       = attrs.GetNamedItem("name").Value;
                    npc.Title      = attrs.GetNamedItem("title").Value;

                    foreach (XmlNode innerData in node.ChildNodes)
                    {
                        WriteTemplateFromNode(innerData, npc);
                    }

                    localNpcTemplates.Add(npc);
                }
            }

            var resultJson = JsonConvert.SerializeObject(localNpcTemplates);

            string outputPath = Directory.GetCurrentDirectory() + @"\" + @"data\json\npcs\";
            var    fileName   = Path.GetFileName(path).Replace(".xml", string.Empty);

            var fileStream = File.Open(Path.Combine(outputPath, fileName + ".json"), FileMode.OpenOrCreate);

            using (var outputFile = new StreamWriter(fileStream))
            {
                outputFile.Write(resultJson);
            }
        }
Esempio n. 19
0
        private void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();
            FileStream  fileStream  = new FileStream(path, FileMode.Open);

            if (fileStream.Length == 0L)
            {
                CLogger.getInstance().info("[PlayerTemplateParser]: File is Empty: " + path);
            }
            else
            {
                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 ("template".Equals(xmlNode2.Name))
                                {
                                    XmlNamedNodeMap xmlNamedNodeMap = (XmlNamedNodeMap)xmlNode2.Attributes;
                                    List <PlayerTemplateInventory> _startInventory = new List <PlayerTemplateInventory>();
                                    int id   = int.Parse(xmlNamedNodeMap.GetNamedItem("id").Value);
                                    int rank = int.Parse(xmlNamedNodeMap.GetNamedItem("rank").Value);
                                    int gp   = int.Parse(xmlNamedNodeMap.GetNamedItem("gp").Value);
                                    int exp  = int.Parse(xmlNamedNodeMap.GetNamedItem("exp").Value);

                                    string   itemid = xmlNamedNodeMap.GetNamedItem("itemid").Value;
                                    string[] _temp  = itemid.Split(new char[] { ';' });
                                    for (int i = 0; i < _temp.Length - 1; i++)
                                    {
                                        string[] _temp2 = _temp[i].Split(new char[] { ',' });
                                        PlayerTemplateInventory _invTemp = new PlayerTemplateInventory();
                                        _invTemp.id      = Int32.Parse(_temp2[0]);
                                        _invTemp.slot    = Int32.Parse(_temp2[1]);
                                        _invTemp.onEquip = Int32.Parse(_temp2[2]);
                                        _startInventory.Add(_invTemp);
                                    }
                                    PlayerTemplate playerTemplate = new PlayerTemplate(id, rank, exp, gp, _startInventory);
                                    _holder.addPlayerTemplateInfo(playerTemplate);
                                }
                            }
                        }
                    }
                }
                catch (XmlException ex)
                {
                    CLogger.getInstance().info("[PlayerTemplateParser]: Error in file: " + path);
                    throw ex;
                }
                fileStream.Close();
            }
        }
        private void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();
            FileStream  fileStream  = new FileStream(path, FileMode.Open);
            bool        flag        = fileStream.Length == 0L;

            if (flag)
            {
                CLogger.getInstance().warning("|[SIIP]| File is Empty: " + path);
            }
            else
            {
                try
                {
                    xmlDocument.Load(fileStream);
                    for (XmlNode xmlNode = xmlDocument.FirstChild; xmlNode != null; xmlNode = xmlNode.NextSibling)
                    {
                        bool flag2 = "list".Equals(xmlNode.Name);
                        if (flag2)
                        {
                            for (XmlNode xmlNode2 = xmlNode.FirstChild; xmlNode2 != null; xmlNode2 = xmlNode2.NextSibling)
                            {
                                bool flag3 = "initial".Equals(xmlNode2.Name);
                                if (flag3)
                                {
                                    XmlNamedNodeMap attributes          = xmlNode2.Attributes;
                                    List <PlayerTemplateInventory> list = new List <PlayerTemplateInventory>();
                                    int    id    = int.Parse(attributes.GetNamedItem("id").Value);
                                    string value = attributes.GetNamedItem("name").Value;
                                    int    slot  = int.Parse(attributes.GetNamedItem("slot").Value);
                                    int    num   = int.Parse(attributes.GetNamedItem("equip").Value);
                                    int    count = int.Parse(attributes.GetNamedItem("count").Value);
                                    PlayerTemplateInventory playerTemplate = new PlayerTemplateInventory
                                    {
                                        id         = id,
                                        name       = value,
                                        slot       = slot,
                                        onEquip    = num,
                                        count      = count,
                                        equip_type = num
                                    };
                                    this._holder.addInventoryStatic(playerTemplate);
                                }
                            }
                        }
                    }
                }
                catch (XmlException ex)
                {
                    CLogger.getInstance().warning("[RankExpInfoParser]: Error in file: " + path);
                    CLogger.getInstance().info(ex.Message);
                }
                fileStream.Close();
            }
        }
Esempio n. 21
0
        public StringObjectSerial(XmlNode _node)
        {
            XmlNamedNodeMap map_       = _node.Attributes;
            String          name_      = _node.Name;
            XmlNode         className_ = map_.GetNamedItem(CLASS);

            if (className_ != null)
            {
                setClassName(className_.Value);
            }
            XmlNode field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                setField(field_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                setKeyOfMap(true);
            }
            //try {
            Type    class_ = Constants.classForName(_node.Name);
            XmlNode value_ = map_.GetNamedItem(VALUE);

            if (value_ == null)
            {
                //throw new NoValueException(name_);
                throw new NoValueException();
            }
            MethodInfo method_ = ConverterMethod.getFromStringMethod(class_);

            if (method_ != null)
            {
                value = method_.Invoke(null, new object[] { value_.Value });
                return;
            }
            if (!typeof(Primitivable).IsAssignableFrom(class_))
            {
                //throw an exception
                throw new ClassFoundException();
            }
            //Class<? extends Primitivable> subClass_ = class_.asSubclass(Primitivable.class);
            ConstructorInfo constr_ = class_.GetConstructor(new Type[] { typeof(string) });

            //constr_.setAccessible(constr_.getAnnotation(RwXml.class)!=null);
            //			constr_.setAccessible(true);
            value = constr_.Invoke(new object[] { value_.Value });

            /*} catch (IllegalArgumentException e) {
             * } catch (IllegalAccessException e) {
             *      e.printStackTrace();*/
            //}
        }
Esempio n. 22
0
        public void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\classes\");
            foreach (string i in xmlFilesArray)
            {
                doc.Load(i);

                XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/class");

                if (nodes == null)
                {
                    continue;
                }

                foreach (XmlNode node in nodes)
                {
                    XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                    if ((ownerElement == null) || (node.Attributes == null) || !"class".Equals(ownerElement.Name))
                    {
                        continue;
                    }

                    XmlNamedNodeMap attrs   = node.Attributes;
                    ClassId         classId = ClassId.Values.FirstOrDefault(x => ((int)x.Id).Equals(Convert.ToInt32(attrs.Item(0).Value)));
                    StatsSet        set     = new StatsSet();

                    for (XmlNode cd = node.FirstChild; cd != null; cd = cd.NextSibling)
                    {
                        if ((cd.NextSibling != null) && "set".Equals(cd.NextSibling.Name) && (cd.NextSibling != null))
                        {
                            attrs = cd.NextSibling.Attributes;
                            if (attrs == null)
                            {
                                continue;
                            }

                            string name  = attrs.GetNamedItem("name").Value;
                            string value = attrs.GetNamedItem("val").Value;
                            set.Set(name, value);
                        }
                        else
                        {
                            break;
                        }
                    }

                    PcTemplate pcTempl = new PcTemplate(classId, set);
                    Templates.Add((int)pcTempl.ClassId.Id, pcTempl);
                }
            }

            Log.Info($"CharTemplateTable: Loaded {Templates.Count} character templates.");
        }
Esempio n. 23
0
        public NumberSerial(XmlNode _node)
        {
            XmlNamedNodeMap map_       = _node.Attributes;
            String          name_      = _node.Name;
            XmlNode         className_ = map_.GetNamedItem(CLASS);

            if (className_ != null)
            {
                setClassName(className_.Value);
            }
            XmlNode field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                setField(field_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                setKeyOfMap(true);
            }
            try {
                //class_ can be a native class inheriting from Number
                //and is found by comparing, in a case insensitive way, its name
                //with the name of a native class inheriting from Number
                XmlNode value_    = map_.GetNamedItem(VALUE);
                Type    t_        = typeof(long);
                string  longType_ = Constants.getTypeFullString(t_);
                t_ = typeof(int);
                string intType_ = Constants.getTypeFullString(t_);
                if (name_.ToLower().Equals(longType_.ToLower()))
                {
                    value = long.Parse(value_.Value) as T?;
                }
                else if (name_.ToLower().Equals(intType_.ToLower()))
                {
                    value = int.Parse(value_.Value) as T?;
                }
                else
                {
                    //class_ does not inherit from Number
                    //throw new ClassFoundException(true, name_, Number.class.getName());
                    throw new ClassFoundException();
                }
                if (value == null)
                {
                    throw new ClassFoundException();
                }
            } catch (NullReferenceException) {
                //throw new NoAttributeForSerializable(VALUE, name_);
                throw new NoAttributeForSerializable();
            }
        }
Esempio n. 24
0
        public static ObjectSerial newSerial(XmlNode _node, bool _requiredClass)
        {
            XmlNamedNodeMap map_    = _node.Attributes;
            ObjectSerial    serial_ = new ObjectSerial();

            if (_requiredClass)
            {
                XmlNode className_ = map_.GetNamedItem(CLASS);
                if (className_ != null)
                {
                    serial_.setClassName(className_.Value);
                }
            }
            XmlNode types_    = map_.GetNamedItem(TYPES);
            string  typesStr_ = "";

            if (types_ != null)
            {
                typesStr_ = types_.Value;
            }
            Type class_ = Constants.classForName(_node.Name, typesStr_);

            serial_.types = class_.GetGenericArguments();
            ConstructorInfo constr_ = class_.GetConstructor(new Type[] { });
            //		constr_.setAccessible(class_.getAnnotation(RwXml.class)!=null);
            //constr_.setAccessible(constr_.getAnnotation(RwXml.class)!=null);
            XmlNode field_ = map_.GetNamedItem(FIELD);

            if (field_ != null)
            {
                serial_.setField(field_.Value);
            }
            XmlNode keyOfMap_ = map_.GetNamedItem(KEY);

            if (keyOfMap_ != null)
            {
                serial_.setKeyOfMap(true);
            }
            try {
                serial_.value = constr_.Invoke(new object[] { });
                //} catch (IllegalArgumentException e) {
                //} catch (IllegalAccessException e) {
                //   e.printStackTrace();

                /*} catch (InstantiationException e) {
                 *      throw e;*/
            } catch (TargetInvocationException e) {
                throw e;
            }
            return(serial_);
        }
        private static void parse(string path)
        {
            XmlDocument xmlDocument = new XmlDocument();

            using (FileStream fileStream = new FileStream(path, FileMode.Open))
            {
                if (fileStream.Length == 0)
                {
                    Printf.warning("[WelcomeXML] O arquivo está vazio: " + path);
                }
                else
                {
                    try
                    {
                        xmlDocument.Load(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 ("msg".Equals(xmlNode2.Name))
                                    {
                                        XmlNamedNodeMap xml = xmlNode2.Attributes;

                                        WelcomeModel ev = new WelcomeModel
                                        {
                                            _title = xml.GetNamedItem("title").Value,
                                            _txt   = xml.GetNamedItem("text").Value,
                                            _color = short.Parse(xml.GetNamedItem("color").Value)
                                        };
                                        _welcome.Add(ev);
                                    }
                                }
                            }
                        }
                        if (_welcome.Count == 0)
                        {
                            Printf.warning("[Aviso] Não existe mensagem de boas vindas");
                        }
                    }
                    catch (XmlException ex)
                    {
                        SaveLog.fatal(ex.ToString());
                        Printf.b_danger("[WelcomeXML.Parse] Erro fatal!");
                    }
                }
                fileStream.Dispose();
                fileStream.Close();
            }
        }
Esempio n. 26
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode PrimaryNode = document.FirstChild; PrimaryNode != null; PrimaryNode = PrimaryNode.NextSibling)
         {
             if ("list".Equals(PrimaryNode.Name))
             {
                 for (XmlNode SecondaryNode = PrimaryNode.FirstChild; SecondaryNode != null; SecondaryNode = SecondaryNode.NextSibling)
                 {
                     if ("Title".Equals(SecondaryNode.Name))
                     {
                         XmlNamedNodeMap PrimaryMap = SecondaryNode.Attributes;
                         int             titleId    = int.Parse(PrimaryMap.GetNamedItem("Id").Value);
                         titles.TryAdd(titleId, new TitleQ(titleId)
                         {
                             classId   = int.Parse(PrimaryMap.GetNamedItem("List").Value),
                             medals    = int.Parse(PrimaryMap.GetNamedItem("Medals").Value),
                             brooch    = int.Parse(PrimaryMap.GetNamedItem("Brooch").Value),
                             blueOrder = int.Parse(PrimaryMap.GetNamedItem("BlueOrder").Value),
                             insignia  = int.Parse(PrimaryMap.GetNamedItem("Insignia").Value),
                             rank      = int.Parse(PrimaryMap.GetNamedItem("Rank").Value),
                             slot      = byte.Parse(PrimaryMap.GetNamedItem("Slot").Value),
                             req1      = int.Parse(PrimaryMap.GetNamedItem("RequestT1").Value),
                             req2      = int.Parse(PrimaryMap.GetNamedItem("RequestT2").Value)
                         });
                         for (XmlNode ThirdNode = SecondaryNode.FirstChild; ThirdNode != null; ThirdNode = ThirdNode.NextSibling)
                         {
                             if ("Item".Equals(ThirdNode.Name))
                             {
                                 XmlNamedNodeMap SecondaryMap = ThirdNode.Attributes;
                                 awards.Add(new TitleA
                                 {
                                     id   = titleId,
                                     item = new ItemsModel(int.Parse(SecondaryMap.GetNamedItem("Id").Value), SecondaryMap.GetNamedItem("Name").Value, byte.Parse(SecondaryMap.GetNamedItem("Equip").Value), int.Parse(SecondaryMap.GetNamedItem("Count").Value))
                                 });
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Exception(ex);
     }
 }
Esempio n. 27
0
 private static void ObjectsXML(XmlNode xmlNode, MapModel map)
 {
     for (XmlNode xmlNode3 = xmlNode.FirstChild; xmlNode3 != null; xmlNode3 = xmlNode3.NextSibling)
     {
         if ("objects".Equals(xmlNode3.Name))
         {
             for (XmlNode xmlNode4 = xmlNode3.FirstChild; xmlNode4 != null; xmlNode4 = xmlNode4.NextSibling)
             {
                 if ("Obj".Equals(xmlNode4.Name))
                 {
                     XmlNamedNodeMap xml4 = xmlNode4.Attributes;
                     ObjModel        obj  = new ObjModel(bool.Parse(xml4.GetNamedItem("NeedSync").Value))
                     {
                         Id    = int.Parse(xml4.GetNamedItem("Id").Value),
                         Life  = int.Parse(xml4.GetNamedItem("Life").Value),
                         Anim1 = int.Parse(xml4.GetNamedItem("Anim1").Value)
                     };
                     if (obj.Life > -1)
                     {
                         obj.IsDestroyable = true;
                     }
                     if (obj.Anim1 > 255)
                     {
                         if (obj.Anim1 == 256)
                         {
                             obj.UltraSYNC = 1;
                         }
                         else if (obj.Anim1 == 257)
                         {
                             obj.UltraSYNC = 2;
                         }
                         else if (obj.Anim1 == 258)
                         {
                             obj.UltraSYNC = 3;
                         }
                         else if (obj.Anim1 == 259)
                         {
                             obj.UltraSYNC = 4;
                         }
                         obj.Anim1 = 255;
                     }
                     AnimsXML(xmlNode4, obj);
                     DEffectsXML(xmlNode4, obj);
                     map.objects.Add(obj);
                 }
             }
         }
     }
 }
Esempio n. 28
0
        public void Test()
        {
            Dictionary <int, NpcTemplate> _npcs = new Dictionary <int, NpcTemplate>();
            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\npcs\");
            try
            {
                StatsSet set = new StatsSet();
                //StatsSet petSet = new StatsSet();

                foreach (string i in xmlFilesArray)
                {
                    doc.Load(i);

                    XmlNodeList nodes = doc.DocumentElement?.SelectNodes("/list/npc");

                    if (nodes == null)
                    {
                        continue;
                    }

                    foreach (XmlNode node in nodes)
                    {
                        XmlElement ownerElement = node.Attributes?[0].OwnerElement;
                        if ((ownerElement != null) && (node.Attributes != null) && "npc".Equals(ownerElement.Name))
                        {
                            XmlNamedNodeMap attrs = node.Attributes;

                            int npcId      = int.Parse(attrs.GetNamedItem("id").Value);
                            int templateId = attrs.GetNamedItem("idTemplate") == null ? npcId : int.Parse(attrs.GetNamedItem("idTemplate").Value);

                            set.Set("id", npcId);
                            set.Set("idTemplate", templateId);
                            set.Set("name", attrs.GetNamedItem("name").Value);
                            set.Set("title", attrs.GetNamedItem("title").Value);

                            _npcs.Add(npcId, new NpcTemplate(set));
                        }
                        set.Clear();
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"MapRegionTest Error: {e.Message}");
                //_log.log(Level.SEVERE, "NpcTable: Error parsing NPC templates : ", e);
            }
        }
Esempio n. 29
0
        private static void GenerateList()
        {
            try
            {
                XmlDocument document = new XmlDocument();
                document.Load(path);
                for (XmlNode PrimaryNode = document.FirstChild; PrimaryNode != null; PrimaryNode = PrimaryNode.NextSibling)
                {
                    if ("list".Equals(PrimaryNode.Name))
                    {
                        for (XmlNode SecondaryNode = PrimaryNode.FirstChild; SecondaryNode != null; SecondaryNode = SecondaryNode.NextSibling)
                        {
                            if ("Rank".Equals(SecondaryNode.Name))
                            {
                                XmlNamedNodeMap PrimaryMap = SecondaryNode.Attributes;
                                byte            rankId     = byte.Parse(PrimaryMap.GetNamedItem("Id").Value);
                                ranks.Add(new RankModel(rankId,
                                                        int.Parse(PrimaryMap.GetNamedItem("NextLevel").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("Gold").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("AllExp").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("Brooch").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("Insignia").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("Medal").Value),
                                                        int.Parse(PrimaryMap.GetNamedItem("BlueOrder").Value)));

                                for (XmlNode ThirdNode = SecondaryNode.FirstChild; ThirdNode != null; ThirdNode = ThirdNode.NextSibling)
                                {
                                    if ("Item".Equals(ThirdNode.Name))
                                    {
                                        XmlNamedNodeMap SecondaryMap = ThirdNode.Attributes;
                                        ItemsModel      item         = new ItemsModel(int.Parse(SecondaryMap.GetNamedItem("Id").Value))
                                        {
                                            name  = SecondaryMap.GetNamedItem("Name").Value,
                                            count = int.Parse(SecondaryMap.GetNamedItem("Count").Value),
                                            equip = byte.Parse(SecondaryMap.GetNamedItem("Equip").Value),
                                        };
                                        AddItemToList(rankId, item);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (XmlException ex)
            {
                Logger.Exception(ex);
            }
        }
Esempio n. 30
0
 private static void GenerateList()
 {
     try
     {
         XmlDocument document = new XmlDocument();
         document.Load(path);
         for (XmlNode xmlNode1 = document.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 xml = xmlNode2.Attributes;
                         MapModel        map = new MapModel
                         {
                             id = int.Parse(xml.GetNamedItem("Id").Value)
                         };
                         BombsXML(xmlNode2, map);
                         ObjectsXML(xmlNode2, map);
                         maps.Add(map);
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
         Logger.Warning(ex.ToString());
     }
 }
Esempio n. 31
0
 protected string GetAttributeValue(string attributeName, XmlNamedNodeMap attributes)
 {
     return attributes.GetNamedItem(attributeName)?.InnerText;
 }