Esempio n. 1
0
    public void AddObjects(XElement root)
    {
        foreach (XElement elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            string cls = elem.Element("Class").Value;
            string id  = elem.Attribute("id").Value;

            ushort     type;
            XAttribute typeAttr = elem.Attribute("type");
            if (typeAttr == null)
            {
                type = assign.Assign(id, elem);
            }
            else
            {
                type = (ushort)Utils.FromString(typeAttr.Value);
            }

            if (type2id_obj.ContainsKey(type))
            {
                log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
            }
            if (id2type_obj.ContainsKey(id))
            {
                log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);
            }

            type2id_obj[type]   = id;
            id2type_obj[id]     = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
            case "Pet":
            case "Dye":
            case "Equipment":
                items[type] = new Item(type, elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type]  = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
                foreach (var eff in items[type].ActivateEffects)
                {
                    if (eff.Effect == ActivateEffects.UnlockSkin)
                    {
                        skin2item[(ushort)eff.SkinType] = items[type];
                    }
                }
                break;

            case "Skin":
                skins[type] = new SkinDesc(type, elem);
                break;

            case "Portal":
                try
                {
                    portals[type] = new PortalDesc(type, elem);
                }
                catch
                {
                    Console.WriteLine("Error for portal: " + type + " id: " + id);

                    /*3392,1792,1795,1796,1805,1806,1810,1825 -- no location, assume nexus?*
                     *  Tomb Portal of Cowardice,  Dungeon Portal,  Portal of Cowardice,  Realm Portal,  Glowing Portal of Cowardice,  Glowing Realm Portal,  Nexus Portal,  Locked Wine Cellar Portal*/
                }
                break;

            default:
                objDescs[type] = new ObjectDesc(type, elem);
                break;
            }

            XAttribute extAttr = elem.Attribute("ext");
            bool       ext;
            if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
            {
                if (elem.Attribute("type") == null)
                {
                    elem.Add(new XAttribute("type", type));
                }
                addition.Add(elem);
                updateCount++;
            }
        }
    }
Esempio n. 2
0
    public void AddObjects(XElement root)
    {
        foreach (XElement elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null)
            {
                continue;
            }
            string cls = elem.Element("Class").Value;
            string id  = elem.Attribute("id").Value;

            ushort     type;
            XAttribute typeAttr = elem.Attribute("type");
            if (typeAttr == null)
            {
                type = assign.Assign(id, elem);
            }
            else
            {
                type = (ushort)Utils.FromString(typeAttr.Value);
            }

            if (type2id_obj.ContainsKey(type))
            {
                log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
            }
            if (id2type_obj.ContainsKey(id))
            {
                log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);
            }

            type2id_obj[type]   = id;
            id2type_obj[id]     = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
            case "Pet":
            case "Dye":
            case "Equipment":
                items[type] = new Item(type, elem);
                if (elem.Element("Shop") != null)
                {
                    XElement shop = elem.Element("Shop");
                    ItemShops[type]  = shop.Element("Name").Value;
                    ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                }
                foreach (var eff in items[type].ActivateEffects)
                {
                    if (eff.Effect == ActivateEffects.UnlockSkin)
                    {
                        skin2item[(ushort)eff.SkinType] = items[type];
                    }
                }
                break;

            case "Skin":
                skins[type] = new SkinDesc(type, elem);
                break;

            case "Portal":
                portals[type]  = new PortalDesc(type, elem);
                objDescs[type] = new ObjectDesc(type, elem);
                break;

            default:
                objDescs[type] = new ObjectDesc(type, elem);
                break;
            }

            XAttribute extAttr = elem.Attribute("ext");
            bool       ext;
            if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
            {
                if (elem.Attribute("type") == null)
                {
                    elem.Add(new XAttribute("type", type));
                }
                addition.Add(elem);
                updateCount++;
            }
        }
    }
Esempio n. 3
0
    public void AddObjects(XElement root)
    {
        foreach (XElement elem in root.XPathSelectElements("//Object"))
        {
            if (elem.Element("Class") == null) continue;
            string cls = elem.Element("Class").Value;
            string id = elem.Attribute("id").Value;

            ushort type;
            XAttribute typeAttr = elem.Attribute("type");
            if (typeAttr == null)
                type = assign.Assign(id, elem);
            else
                type = (ushort) Utils.FromString(typeAttr.Value);

            if (type2id_obj.ContainsKey(type))
                log.WarnFormat("'{0}' and '{1}' has the same ID of 0x{2:x4}!", id, type2id_obj[type], type);
            if (id2type_obj.ContainsKey(id))
                log.WarnFormat("0x{0:x4} and 0x{1:x4} has the same name of {2}!", type, id2type_obj[id], id);

            type2id_obj[type] = id;
            id2type_obj[id] = type;
            type2elem_obj[type] = elem;

            switch (cls)
            {
                case "Pet":
                case "Dye":
                case "Equipment":
                    items[type] = new Item(type, elem);
                    if (elem.Element("Shop") != null)
                    {
                        XElement shop = elem.Element("Shop");
                        ItemShops[type] = shop.Element("Name").Value;
                        ItemPrices[type] = Utils.FromString(shop.Element("Price").Value);
                    }
                    foreach(var eff in items[type].ActivateEffects)
                        if (eff.Effect == ActivateEffects.UnlockSkin)
                            skin2item[(ushort)eff.SkinType] = items[type];
                    break;
                case "Skin":
                    skins[type] = new SkinDesc(type, elem);
                    break;
                case "Portal":
                    portals[type] = new PortalDesc(type, elem);
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
                default:
                    objDescs[type] = new ObjectDesc(type, elem);
                    break;
            }

            XAttribute extAttr = elem.Attribute("ext");
            bool ext;
            if (extAttr != null && bool.TryParse(extAttr.Value, out ext) && ext)
            {
                if (elem.Attribute("type") == null)
                    elem.Add(new XAttribute("type", type));
                addition.Add(elem);
                updateCount++;
            }
        }
    }