Ejemplo n.º 1
0
void TileMapObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
{
    if(element.HasChild("tileSet"))
    {
        tileSet.Get().UnserializeFrom(element.GetChild("tileSet"));
    }
    if(element.HasChild("tileMap"))
    {
        tileMap.Get().UnserializeFrom(element.GetChild("tileMap"));
    }
}
Ejemplo n.º 2
0
void ScenePathDatas::UnserializeFrom(const gd::SerializerElement & element)
{
    globalPaths.clear();

    if (!element.HasChild("paths", "Paths")) return;

    const gd::SerializerElement & pathsElement = element.GetChild("paths", 0, "Paths");
    pathsElement.ConsiderAsArrayOf("path", "Path");
    for (int i = 0; i < pathsElement.GetChildrenCount(); ++i)
    {
        const gd::SerializerElement & pathElement = pathsElement.GetChild(i);

        globalPaths[pathElement.GetStringAttribute("name")] = PathBehavior::GetCoordsVectorFromString(pathElement.GetStringAttribute("coords"), '/', ';');
    }

}
Ejemplo n.º 3
0
void TileSet::UnserializeFrom(const gd::SerializerElement &element)
{
    int serializationVersion = element.GetIntAttribute("version", 1);

    textureName = element.GetStringAttribute("textureName", "");
    tileSize.x = element.GetIntAttribute("tileSizeX", 32);
    tileSize.y = element.GetIntAttribute("tileSizeY", 32);
    tileSpacing.x = element.GetIntAttribute("tileSpacingX", 0);
    tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0);

    ResetHitboxes();
    m_collidable.clear();

    if(serializationVersion == 1)
    {
        if(element.HasChild("hitboxes"))
        {
            gd::SerializerElement &tilesElem = element.GetChild("hitboxes");
            tilesElem.ConsiderAsArrayOf("tileHitbox");
            for(int i = 0; i < tilesElem.GetChildrenCount("tileHitbox"); i++)
            {
                m_collidable.push_back(tilesElem.GetChild(i).GetBoolAttribute("collidable", true));
                TileHitbox newHitbox;
                newHitbox.UnserializeFrom(tilesElem.GetChild(i), tileSize);
                if(newHitbox != TileHitbox::Rectangle(tileSize))
                    m_hitboxes[i] = newHitbox;
            }
        }
    }
    else if(serializationVersion == 2)
    {
        gd::SerializerElement &collidableElem = element.GetChild("collidable");
        collidableElem.ConsiderAsArrayOf("tile");
        for(int i = 0; i < collidableElem.GetChildrenCount("tile"); i++)
        {
            m_collidable.push_back(collidableElem.GetChild(i).GetBoolAttribute("collidable", true));
        }

        gd::SerializerElement &hitboxesElem = element.GetChild("hitboxes");
        hitboxesElem.ConsiderAsArrayOf("tileHitbox");
        for(int i = 0; i < hitboxesElem.GetChildrenCount("tileHitbox"); i++)
        {
            m_hitboxes[hitboxesElem.GetChild(i).GetIntAttribute("tileId", -1)].UnserializeFrom(hitboxesElem.GetChild(i), tileSize);
        }
    }
}
Ejemplo n.º 4
0
void TileSet::UnserializeFrom(const gd::SerializerElement &element)
{
    ResetHitboxes();

    textureName = element.GetStringAttribute("textureName", "");
    tileSize.x = element.GetIntAttribute("tileSizeX", 32);
    tileSize.y = element.GetIntAttribute("tileSizeY", 32);
    tileSpacing.x = element.GetIntAttribute("tileSpacingX", 0);
    tileSpacing.y = element.GetIntAttribute("tileSpacingY", 0);

    if (element.HasChild("hitboxes"))
    {
        gd::SerializerElement &tilesElem = element.GetChild("hitboxes");
        tilesElem.ConsiderAsArrayOf("tileHitbox");
        for(int i = 0; i < tilesElem.GetChildrenCount("tileHitbox"); i++)
        {
            TileHitbox newHitbox;
            newHitbox.UnserializeFrom(tilesElem.GetChild(i), tileSize);
            m_hitboxes.push_back(newHitbox);
        }
    }

    m_dirty = true;
}