Ejemplo n.º 1
0
void DataManager::parseData( XmlTree d ){
    XmlTree data  = d.getChild( "QLT_Genome_Data" );
    string dataPath = data.getChild( "datapath" ).getValue();
    XmlTree sets = data.getChild( "datasets");
    for( XmlTree::Iter dataset = sets.begin(); dataset != sets.end(); ++dataset ){
        GenomeDataStructure gds;
        gds.id = dataset->getAttributeValue<int>("id");
        gds.name = dataset->getChild("title").getValue();
        gds.pathMap = dataPath+dataset->getChild("map").getValue();
        gds.pathBases = dataPath+dataset->getChild("bases").getValue();
        mDataStructure.push_back( gds );
        console() << " GenomeDataStructure : " << gds.name << "         " << gds.pathMap << "   " << gds.pathBases << std::endl;
    }
}
Ejemplo n.º 2
0
void Level::loadLevelFromFile(string pathToLevel)
{   
    // root
    id = pathToLevel;
    string realPath = "levels/" + pathToLevel;
    realPath = getAssetPath(realPath).string();
    XmlTree doc((loadFile(realPath)));
    XmlTree root = doc.getChild("level");
    
    // width + height
    width = root.getChild("width").getValue<int>();
    height = root.getChild("height").getValue<int>();
    Map.resize(width, vector<int>(height, -1));
    
    // hero start position
    int hx = root.getChild("heroX").getValue<int>();
    int hy = root.getChild("heroY").getValue<int>();
    hero.position.set(hx * TILESIZE, hy * TILESIZE);
    
    // antenna
    int ax = root.getChild("antennaX").getValue<int>();
    int ay = root.getChild("antennaY").getValue<int>();
    antennaPosition.set(ax * TILESIZE, ay * TILESIZE);
    
    // level-data
    stringstream stream;
    stream << root.getChild("data").getValue();
    int index = 0;
    while (stream.good() && index < width * height) {
        int tileId;
        stream >> tileId;
        setTileAtPosition(index, tileId);
        index++;
    }
    
    // attractors
    if (root.hasChild("attractors")) {
        XmlTree firstAttractor = root.getChild("attractors");
        for (XmlTree::Iter child = firstAttractor.begin(); child != firstAttractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Attractor* attractor = new Attractor(x, y);
            attractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(attractor->autoConnectTime);
            attractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            attractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            attractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            attractor->attractForce = child->getChild("attractForce").getValue<float>(attractor->attractForce);
            attractor->maxAttractForce = child->getChild("maxAttractForce").getValue<float>(attractor->maxAttractForce);
            
            addConnector(attractor);
        }
    }
    
    // detractors
    if (root.hasChild("detractors")) {
        XmlTree firstDetractor = root.getChild("detractors");
        for (XmlTree::Iter child = firstDetractor.begin(); child != firstDetractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Detractor* detractor = new Detractor(x, y);
            detractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(detractor->autoConnectTime);
            detractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            detractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            detractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            detractor->bounceForce = child->getChild("bounceForce").getValue<float>(detractor->bounceForce);
            detractor->maxBounceForce = child->getChild("maxBounceForce").getValue<float>(detractor->maxBounceForce);
            
            addConnector(detractor);
        }
    }
    
}