internal QuestRequirement(XmlElement e)
        {
            if (!e.HasAttribute("type"))
            {
                throw new XmlException("QuestRequirement does not have a type assigned!");
            }

            type          = e.GetAttribute("type");
            id            = e.GetAttribute("id");
            value         = e.GetAttribute("value");
            hidden        = (bool)Utils.GetAttribute <bool>(e, "hidden", false);
            optional      = (bool)Utils.GetAttribute <bool>(e, "optional", false);
            isChosen      = (bool)Utils.GetAttribute <bool>(e, "isChosen", false);
            isfixed       = (bool)Utils.GetAttribute <bool>(e, "isfixed", false);
            isChainReward = (bool)Utils.GetAttribute <bool>(e, "isChainReward", false);
            Enum.TryParse(e.GetAttribute("stage"), out stage);

            if (type.Equals("group"))
            {
                foreach (XmlNode child in e.ChildNodes)
                {
                    try {
                        if (child.Name.Equals("requirement"))
                        {
                            QuestRequirement requirement = new QuestRequirement(child as XmlElement);
                            childRequirements[requirement.type] = requirement;
                        }
                    } catch (XmlException) {}
                }
            }
        }
示例#2
0
        internal Quest(XmlElement e)
        {
            if (!e.HasAttribute("id"))
            {
                throw new XmlException("Quest does not have id assigned!");
            }

            id             = e.GetAttribute("id");
            groupName      = e.GetAttribute("group_name_key");
            name           = e.GetAttribute("name_key");
            subtitle       = e.GetAttribute("subtitle_key");
            description    = e.GetAttribute("description_key");
            icon           = e.GetAttribute("icon");
            category       = e.GetAttribute("category_key");
            offer          = e.GetAttribute("offer_key");
            statement      = e.GetAttribute("statement_key");
            response       = e.GetAttribute("response_key");
            completion     = e.GetAttribute("completion_key");
            shareable      = (bool)Utils.GetAttribute <bool>(e, "shareable", true);
            repeatable     = (bool)Utils.GetAttribute <bool>(e, "repeatable", false);
            currentVersion = (byte)Utils.GetAttribute <byte>(e, "currentVersion", 0);
            Enum.TryParse(e.GetAttribute("difficulty"), out difficulty);
            Enum.TryParse(e.GetAttribute("completiontype"), out completionType);

            foreach (XmlElement child in e.ChildNodes)
            {
                try {
                    switch (child.Name)
                    {
                    case "action":
                        QuestAction action = new QuestAction(child);
                        actions[action.id] = action;
                        break;

                    case "requirement":
                        QuestRequirement requirement = new QuestRequirement(child);
                        requirements[requirement.id] = requirement;
                        break;

                    case "objective":
                        QuestObjective objective = new QuestObjective(child);
                        objectives[objective.id] = objective;
                        break;

                    case "reward":
                        QuestRewards reward = new QuestRewards(child);
                        rewards[reward.id] = reward;
                        break;

                    case "quest_criteria":
                    case "offer_criteria":
                        QuestCriteria criterium = new QuestCriteria(child);
                        criteria[criterium.id] = criterium;
                        break;

                    default:
                        break;
                    }
                } catch (XmlException) {}
            }
        }