Пример #1
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: ");
            }
        }
Пример #2
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);
            }
        }
Пример #3
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}");
                }
            }
        }
Пример #4
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.");
        }
Пример #5
0
        public void TestMethod1()
        {
            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\");
            for (int i = 0; i < xmlFilesArray.Length; i++)
            {
                doc.Load(xmlFilesArray[i]);
                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/list/class");

                foreach (XmlNode node in nodes)
                {
                    if ("class".Equals(node.Attributes[0].OwnerElement.Name))
                    {
                        XmlNamedNodeMap attrs   = node.Attributes;
                        ClassIds        classId = (ClassIds)int.Parse(attrs.Item(0).Value);
                        StatsSet        set     = new StatsSet();

                        for (XmlNode cd = node.FirstChild; cd != null; cd = cd.NextSibling)
                        {
                            if ("set".Equals(cd.NextSibling.Name) && cd.NextSibling != null)
                            {
                                attrs = cd.NextSibling.Attributes;
                                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);
                    }
                }
            }
        }
Пример #6
0
        public void Initialize()
        {
            XmlDocument doc = new XmlDocument();

            string[] xmlFilesArray = Directory.GetFiles(@"data\xml\classes\");
            for (int i = 0; i < xmlFilesArray.Length; i++)
            {
                doc.Load(xmlFilesArray[i]);
                XmlNodeList nodes = doc.DocumentElement.SelectNodes("/list/class");

                foreach (XmlNode node in nodes)
                {
                    if ("class".Equals(node.Attributes[0].OwnerElement.Name))
                    {
                        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 ("set".Equals(cd.NextSibling.Name) && cd.NextSibling != null)
                            {
                                attrs = cd.NextSibling.Attributes;
                                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($"Loaded { templates.Count } character templates.");
        }
Пример #7
0
        public static void Initialize()
        {
            _templates = new Dictionary <int, PcTemplate>();

            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 || ownerElement.Name != "class")
                    {
                        continue;
                    }

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

                    for (XmlNode cd = node.FirstChild; cd?.NextSibling != null; cd = cd.NextSibling)
                    {
                        if (cd.NextSibling.Name == "set")
                        {
                            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 if (cd.NextSibling.Name == "items")
                        {
                            attrs = cd.NextSibling.Attributes;

                            if (attrs == null)
                            {
                                continue;
                            }

                            string value = attrs.GetNamedItem("val").Value;

                            set.Set("items", value);
                        }
                    }

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

            Log.Info($"Loaded {_templates.Count} character templates.");
        }