Exemplo n.º 1
0
    public Objectives(XmlNode objectivesNode)
    {
        XmlNodeList winNodes = objectivesNode.SelectNodes("win");

        foreach (XmlNode winNode in winNodes)
        {
            XmlAttributeCollection winAttributes = winNode.Attributes;
            long   id       = Misc.xmlLong(winAttributes.GetNamedItem("id"));
            string type     = Misc.xmlString(winAttributes.GetNamedItem("type"));
            string label    = Misc.xmlString(winAttributes.GetNamedItem("label"));
            long   targetId = Misc.xmlLong(winAttributes.GetNamedItem("targetId"));
            string key      = Misc.xmlString(winAttributes.GetNamedItem("key"));
            float  value    = Misc.xmlFloat(winAttributes.GetNamedItem("value"));
            winObjectives.Add(new Objective(id, type, label, targetId, key, value));
        }

        XmlNodeList loseNodes = objectivesNode.SelectNodes("lose");

        foreach (XmlNode loseNode in loseNodes)
        {
            XmlAttributeCollection loseAttributes = loseNode.Attributes;
            long   id       = Misc.xmlLong(loseAttributes.GetNamedItem("id"));
            string type     = Misc.xmlString(loseAttributes.GetNamedItem("type"));
            string label    = Misc.xmlString(loseAttributes.GetNamedItem("label"));
            long   targetId = Misc.xmlLong(loseAttributes.GetNamedItem("targetId"));
            string key      = Misc.xmlString(loseAttributes.GetNamedItem("key"));
            float  value    = Misc.xmlFloat(loseAttributes.GetNamedItem("value"));
            loseObjectives.Add(new Objective(id, type, label, targetId, key, value));
        }

        XmlAttributeCollection objectiveAttributes = objectivesNode.Attributes;

        if (objectiveAttributes.GetNamedItem("winCombos") != null)
        {
            winCombos = Misc.parseLongMultiList(Misc.xmlString(objectiveAttributes.GetNamedItem("winCombos")), ';', ',');
        }
        else
        {
            List <long> winCombo = new List <long> ();
            foreach (Objective winObjective in winObjectives)
            {
                winCombo.Add(winObjective.id);
            }
            winCombos.Add(winCombo);
        }

        if (objectiveAttributes.GetNamedItem("loseCombos") != null)
        {
            loseCombos = Misc.parseLongMultiList(Misc.xmlString(objectiveAttributes.GetNamedItem("loseCombos")), ';', ',');
        }
        else
        {
            foreach (Objective loseObjective in loseObjectives)
            {
                loseCombos.Add(new List <long> ()
                {
                    loseObjective.id
                });
            }
        }


        SpecialObjectives.clearCache();
        DataCollector.registerObjectiveReporter(this);
    }