Package org.freerealm.vegetation

Examples of org.freerealm.vegetation.VegetationImpl


        xml.append("</Vegetation>\n");
        return xml.toString();
    }

    public Vegetation initializeFromNode(Realm realm, Node node) {
        VegetationImpl vegetationImpl = new VegetationImpl();
        Node idNode = XMLConverterUtility.findNode(node, "id");
        int id = Integer.parseInt(idNode.getFirstChild().getNodeValue());
        vegetationImpl.setId(id);
        Node nameNode = XMLConverterUtility.findNode(node, "name");
        String name = nameNode.getFirstChild().getNodeValue();
        vegetationImpl.setName(name);
        Node turnsNeededToClearNode = XMLConverterUtility.findNode(node, "turnsNeededToClear");
        int turnsNeededToClear = Integer.parseInt(turnsNeededToClearNode.getFirstChild().getNodeValue());
        vegetationImpl.setTurnsNeededToClear(turnsNeededToClear);
        Node tileTypesNode = XMLConverterUtility.findNode(node, "tileTypes");
        for (Node subNode = tileTypesNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("tileTypeId")) {
                    int tileTypeId = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    TileType tileType = realm.getTileTypeManager().getTileType(tileTypeId);
                    vegetationImpl.addGrowableTileType(tileType);
                }
            }
        }
        Node propertiesNode = XMLConverterUtility.findNode(node, "properties");
        for (Node propertyNode = propertiesNode.getFirstChild(); propertyNode != null; propertyNode = propertyNode.getNextSibling()) {
            if (propertyNode.getNodeType() == Node.ELEMENT_NODE) {
                Property property = PropertyFactory.createProperty(realm, propertyNode);
                vegetationImpl.addProperty(property);
            }
        }
        return vegetationImpl;
    }
View Full Code Here

TOP

Related Classes of org.freerealm.vegetation.VegetationImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.