Exemplo n.º 1
0
    public void Load(XmlDocument listXmlRoot)
    {
        XmlNode rosterXml = listXmlRoot["roster"];

        _name = rosterXml.Attributes["name"].Value;

        Debug.LogFormat("RosterList: Loading roster \"{0}\"", _name);

        // Load cost limits
        XmlNodeList costLimitsXmlList =
            rosterXml.SelectNodes("//*[local-name()='costLimits']/*[local-name()='costLimit']");

        for (int i = 0; i < costLimitsXmlList.Count; i++)
        {
            var costLimitXml = costLimitsXmlList.Item(i);
            switch (costLimitXml.Attributes["typeId"].Value)
            {
            case "points":     // Points typeId
                double.TryParse(costLimitXml.Attributes["value"].Value, out _pointsLimit);
                break;

            case "e356-c769-5920-6e14":     // PL typeId
                double.TryParse(costLimitXml.Attributes["value"].Value, out _powerLevelLimit);
                break;

            default:
                Debug.LogWarningFormat("RosterList: Ignoring unknown type of cost limit " +
                                       "\"{0}\"", costLimitXml.Attributes["typeId"].Value);
                break;
            }
        }

        // Load forces
        XmlNodeList forcesListXml =
            rosterXml.SelectNodes("//*[local-name()='forces']/*[local-name()='force']");

        //Debug.LogFormat("RosterList: Number of force entries \"{0}\"", forcesListXml.Count);

        for (int i = 0; i < forcesListXml.Count; i++)
        {
            var forceXml = forcesListXml.Item(i);

            Detachment newDetachment = new Detachment();

            newDetachment.Load(forceXml);

            _detachments.Add(newDetachment);
        }
    }