Exemplo n.º 1
0
    void ReadXml_InstalledObjects(XmlReader reader)
    {
        if (reader.ReadToDescendant("InstalledObject"))
        {
            do
            {
                int x = int.Parse(reader.GetAttribute("X"));
                int y = int.Parse(reader.GetAttribute("Y"));

                InstalledObject obj = PlaceInstalledObject(reader.GetAttribute("ObjectType"), _tiles[x, y]);
                obj.ReadXml(reader);
            } while (reader.ReadToNextSibling("InstalledObject"));
        }
    }
Exemplo n.º 2
0
    void ReadXml_InstalledObjects(XmlReader _reader)
    {
        //We are in the InstalledObjects element, read it's descendant elements named InstalledObject until we run out



        if (_reader.ReadToDescendant("InstalledObject"))
        {
            do
            {
                //Read X and Y attributes of the Tile element
                int x = int.Parse(_reader.GetAttribute("X"));
                int y = int.Parse(_reader.GetAttribute("Y"));

                InstalledObject inObj = PlaceInstalledObject(_reader.GetAttribute("ObjectType"), tiles[x, y]);
                //Things like movementCost or health set in the inObj's ReadXml
                inObj.ReadXml(_reader);
            }while (_reader.ReadToNextSibling("InstalledObject"));
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Loop through all 'InstalledObject' nodes in the 'InstalledObjects' element of the Xml-file
    /// </summary>
    /// <param name="reader">Needs XmlReader, so it's all from the same reader</param>
    void ReadXml_IstalledObjects(XmlReader reader)
    {
        // If true, there is at least one tile
        if (reader.ReadToDescendant("InstalledObject"))
        {
            // Do-while loop, will run at least once, but will stop if the while statement isn't true anymore
            // So if there are no more "InstalledObject" siblings left
            do
            {
                // Get the InstalledObject position for each InstalledObject
                int x = int.Parse(reader.GetAttribute("X"));
                int y = int.Parse(reader.GetAttribute("Y"));

                // Place installedObject from Xml-file
                InstalledObject installedObject = PlaceInstalledObject(reader.GetAttribute("ObjectType"), tiles[x, y]);
                installedObject.ReadXml(reader);
            }
            // Loop through all sibling elements
            while (reader.ReadToNextSibling("InstalledObject"));
        }
    }