Пример #1
0
        private void Parse(string itemInfoXmlString, string itemTooltipXmlString)
        {
            XDocument itemInfoXml    = XDocument.Parse(itemInfoXmlString);
            XDocument itemTooltipXml = XDocument.Parse(itemTooltipXmlString);

            ItemInfoProvider.PopulateWithItemInfoXml(this, itemInfoXml);
            ItemInfoProvider.PopulateWithItemTooltipXml(this, itemTooltipXml);
        }
Пример #2
0
        public static void PopulateItemData(XDocument xdocument, CharacterInfo characterSheet)
        {
            try
            {
                XElement xelement = xdocument.XPathSelectElement("/page/characterInfo/characterTab/items");
                foreach (XElement itemElement in xelement.XPathSelectElements("item"))
                {
                    ItemInfo itemInfo = null;
                    foreach (XAttribute attribute in itemElement.Attributes())
                    {
                        if (attribute.Name.LocalName == "id")
                        {
                            itemInfo = ItemInfoProvider.LoadFrom(attribute.Value);
                            break;
                        }
                    }

                    if (itemInfo == null)
                    {
                        continue;
                    }

                    // process character-specific item data
                    foreach (XAttribute attribute in itemElement.Attributes())
                    {
                        switch (attribute.Name.LocalName)
                        {
                        //case "icon":
                        //    itemInfo.Icon = attribute.Value as string;
                        //    break;
                        case "durability":
                            itemInfo.Durability = attribute.Value as string;
                            break;

                        case "maxDurability":
                            itemInfo.MaxDurability = attribute.Value as string;
                            break;

                        case "slot":
                            itemInfo.Slot = attribute.Value as string;
                            switch (itemInfo.Slot)
                            {
                            case "0":         // Head
                                characterSheet.Head = itemInfo;
                                break;

                            case "1":         // Neck
                                characterSheet.Neck = itemInfo;
                                break;

                            case "2":         // Shoulders
                                characterSheet.Shoulders = itemInfo;
                                break;

                            case "3":         // Shirt
                                characterSheet.Shirt = itemInfo;
                                break;

                            case "4":         // Chest
                                characterSheet.Chest = itemInfo;
                                break;

                            case "5":         // Waist
                                characterSheet.Waist = itemInfo;
                                break;

                            case "6":         // Legs
                                characterSheet.Legs = itemInfo;
                                break;

                            case "7":         // Feet
                                characterSheet.Feet = itemInfo;
                                break;

                            case "8":         // Wrist
                                characterSheet.Wrist = itemInfo;
                                break;

                            case "10":         // Finger1
                                characterSheet.Finger1 = itemInfo;
                                break;

                            case "11":         // Finger2
                                characterSheet.Finger2 = itemInfo;
                                break;

                            case "12":         // Trinket1
                                characterSheet.Trinket1 = itemInfo;
                                break;

                            case "13":         // Trinket2
                                characterSheet.Trinket2 = itemInfo;
                                break;

                            case "14":         // Back
                                characterSheet.Back = itemInfo;
                                break;

                            case "15":         // MainHand
                                characterSheet.MainHand = itemInfo;
                                break;

                            case "16":         // OffHand
                                characterSheet.OffHand = itemInfo;
                                break;

                            case "17":         // Ranged
                                characterSheet.Ranged = itemInfo;
                                break;

                            default:
                                // TODO log unknown slot
                                break;
                            }
                            break;

                        default:
                            break;
                        }
                    }
                    // TODO
                }
            }
            catch (Exception ex)
            {
                // TODO error reporting
                Debug.WriteLine(ex.Message + "|" + ex.StackTrace);
            }
        }