Esempio n. 1
0
TopDownMovementRuntimeBehavior::TopDownMovementRuntimeBehavior(
    const gd::SerializerElement& behaviorContent)
    : RuntimeBehavior(behaviorContent),
      allowDiagonals(true),
      acceleration(400),
      deceleration(800),
      maxSpeed(200),
      angularMaxSpeed(180),
      rotateObject(true),
      angleOffset(0),
      xVelocity(0),
      yVelocity(0),
      angularSpeed(0),
      angle(0),
      ignoreDefaultControls(false),
      leftKey(false),
      rightKey(false),
      upKey(false),
      downKey(false) {
  allowDiagonals = behaviorContent.GetBoolAttribute("allowDiagonals");
  acceleration = behaviorContent.GetDoubleAttribute("acceleration");
  deceleration = behaviorContent.GetDoubleAttribute("deceleration");
  maxSpeed = behaviorContent.GetDoubleAttribute("maxSpeed");
  angularMaxSpeed = behaviorContent.GetDoubleAttribute("angularMaxSpeed");
  rotateObject = behaviorContent.GetBoolAttribute("rotateObject");
  angleOffset = behaviorContent.GetDoubleAttribute("angleOffset");
  ignoreDefaultControls =
      behaviorContent.GetBoolAttribute("ignoreDefaultControls");
}
Esempio n. 2
0
void PathBehavior::UnserializeFrom(const gd::SerializerElement & element)
{
    UnserializePathsFrom(element.GetChild("paths", 0, "Paths"));

    ChangeCurrentPath(element.GetStringAttribute("currentPath"));
    speed = element.GetDoubleAttribute("speed");
    offset.x = element.GetDoubleAttribute("offsetX");
    offset.y = element.GetDoubleAttribute("offsetY");
    angleOffset = element.GetDoubleAttribute("angleOffset");
    reverseAtEnd = element.GetBoolAttribute("reverseAtEnd");
    stopAtEnd = element.GetBoolAttribute("stopAtEnd");
    followAngle = element.GetBoolAttribute("followAngle");
}
Esempio n. 3
0
void PhysicsBehavior::UnserializeFrom(const gd::SerializerElement & element)
{
    dynamic = element.GetBoolAttribute("dynamic");
    fixedRotation = element.GetBoolAttribute("fixedRotation");
    isBullet = element.GetBoolAttribute("isBullet");
    massDensity = element.GetDoubleAttribute("massDensity");
    averageFriction = element.GetDoubleAttribute("averageFriction");
    averageRestitution = element.GetDoubleAttribute("averageRestitution");

    linearDamping = element.GetDoubleAttribute("linearDamping");
    angularDamping = element.GetDoubleAttribute("angularDamping");

    gd::String shape = element.GetStringAttribute("shapeType");
    if ( shape == "Circle" )
        shapeType = Circle;
    else if (shape == "CustomPolygon")
        shapeType = CustomPolygon;
    else
        shapeType = Box;

    if(element.GetStringAttribute("positioning", "OnOrigin") == "OnOrigin")
        polygonPositioning = OnOrigin;
    else
        polygonPositioning = OnCenter;

    automaticResizing = element.GetBoolAttribute("autoResizing", false);
    polygonWidth = element.GetDoubleAttribute("polygonWidth");
    polygonHeight = element.GetDoubleAttribute("polygonHeight");

    gd::String coordsStr = element.GetStringAttribute("coordsList");
    SetPolygonCoords(PhysicsBehavior::GetCoordsVectorFromString(coordsStr, '/', ';'));
}
Esempio n. 4
0
void PathfindingBehavior::UnserializeFrom(const gd::SerializerElement & element)
{
    allowDiagonals = element.GetBoolAttribute("allowDiagonals");
    acceleration = element.GetDoubleAttribute("acceleration");
    maxSpeed = element.GetDoubleAttribute("maxSpeed");
    angularMaxSpeed = element.GetDoubleAttribute("angularMaxSpeed");
    rotateObject = element.GetBoolAttribute("rotateObject");
    angleOffset = element.GetDoubleAttribute("angleOffset");
    extraBorder = element.GetDoubleAttribute("extraBorder");
    {
        int value = element.GetIntAttribute("cellWidth", 0);
        if (value > 0) cellWidth = value;
    }
    {
        int value = element.GetIntAttribute("cellHeight", 0);
        if (value > 0) cellHeight = value;
    }
}
void PlatformerObjectBehavior::UnserializeFrom(const gd::SerializerElement & element)
{
    gravity = element.GetDoubleAttribute("gravity");
    maxFallingSpeed = element.GetDoubleAttribute("maxFallingSpeed");
    acceleration = element.GetDoubleAttribute("acceleration");
    deceleration = element.GetDoubleAttribute("deceleration");
    maxSpeed = element.GetDoubleAttribute("maxSpeed");
    jumpSpeed = element.GetDoubleAttribute("jumpSpeed");
    ignoreDefaultControls = element.GetBoolAttribute("ignoreDefaultControls");
    SetSlopeMaxAngle(element.GetDoubleAttribute("slopeMaxAngle"));
    canGrabPlatforms = element.GetBoolAttribute("canGrabPlatforms", false);
    yGrabOffset = element.GetDoubleAttribute("yGrabOffset");
    xGrabTolerance = element.GetDoubleAttribute("xGrabTolerance", 10);
}
Esempio n. 6
0
void Direction::UnserializeFrom(const gd::SerializerElement & element)
{
    SetTimeBetweenFrames(element.GetDoubleAttribute("timeBetweenFrames", 1, "tempsEntre"));
    SetLoop(element.GetBoolAttribute("looping", false, "boucle"));

    const gd::SerializerElement & spritesElement = element.GetChild("sprites", 0, "Sprites");
    spritesElement.ConsiderAsArrayOf("sprite", "Sprite");
    for (unsigned int i = 0; i < spritesElement.GetChildrenCount(); ++i)
    {
        const gd::SerializerElement & spriteElement = spritesElement.GetChild(i);
        Sprite sprite;

        sprite.SetImageName(spriteElement.GetStringAttribute("image"));
        OpenPointsSprites(sprite.GetAllNonDefaultPoints(), spriteElement.GetChild("points", 0, "Points"));

        OpenPoint(sprite.GetOrigin(), spriteElement.GetChild("originPoint" , 0, "PointOrigine"));
        OpenPoint(sprite.GetCenter(), spriteElement.GetChild("centerPoint" , 0, "PointCentre"));
        sprite.SetDefaultCenterPoint(spriteElement.GetChild("centerPoint" , 0, "PointCentre").GetBoolAttribute("automatic", true));

        if (spriteElement.HasChild("CustomCollisionMask"))
            sprite.SetCollisionMaskAutomatic(!spriteElement.GetChild("CustomCollisionMask").GetBoolAttribute("custom", false));
        else
            sprite.SetCollisionMaskAutomatic(!spriteElement.GetBoolAttribute("hasCustomCollisionMask", false));

        std::vector<Polygon2d> mask;
        const gd::SerializerElement & collisionMaskElement = spriteElement.GetChild("customCollisionMask", 0, "CustomCollisionMask");
        collisionMaskElement.ConsiderAsArrayOf("polygon", "Polygon");
        for (unsigned int j = 0; j < collisionMaskElement.GetChildrenCount(); ++j)
        {
            Polygon2d polygon;

            const gd::SerializerElement & polygonElement = collisionMaskElement.GetChild(j);
            polygonElement.ConsiderAsArrayOf("vertice", "Point");
            for (unsigned int k = 0; k < polygonElement.GetChildrenCount(); ++k)
            {
                const gd::SerializerElement & verticeElement = polygonElement.GetChild(k);

                polygon.vertices.push_back(sf::Vector2f(verticeElement.GetDoubleAttribute("x"),
                    verticeElement.GetDoubleAttribute("y")));
            }

            mask.push_back(polygon);
        }
        sprite.SetCustomCollisionMask(mask);

        sprites.push_back(sprite);
    }
};
Esempio n. 7
0
void PlatformerObjectAutomatism::UnserializeFrom(const gd::SerializerElement & element)
{
    gravity = element.GetDoubleAttribute("gravity");
    maxFallingSpeed = element.GetDoubleAttribute("maxFallingSpeed");
    acceleration = element.GetDoubleAttribute("acceleration");
    deceleration = element.GetDoubleAttribute("deceleration");
    maxSpeed = element.GetDoubleAttribute("maxSpeed");
    jumpSpeed = element.GetDoubleAttribute("jumpSpeed");
    ignoreDefaultControls = element.GetBoolAttribute("ignoreDefaultControls");
    SetSlopeMaxAngle(element.GetDoubleAttribute("slopeMaxAngle"));
}
Esempio n. 8
0
void TiledSpriteObject::DoUnserializeFrom(gd::Project & project, const gd::SerializerElement & element)
{
    textureName = element.GetStringAttribute("texture");
    width = element.GetDoubleAttribute("width", 128);
    height = element.GetDoubleAttribute("height", 128);
}
Esempio n. 9
0
void ScenePhysicsDatas::UnserializeFrom(const gd::SerializerElement& element) {
  gravityX = element.GetDoubleAttribute("gravityX");
  gravityY = element.GetDoubleAttribute("gravityY");
  scaleX = element.GetDoubleAttribute("scaleX");
  scaleY = element.GetDoubleAttribute("scaleY");
}
Esempio n. 10
0
void PathfindingObstacleAutomatism::UnserializeFrom(const gd::SerializerElement & element)
{
    impassable = element.GetBoolAttribute("impassable");
    cost = element.GetDoubleAttribute("cost");
}
Esempio n. 11
0
void DestroyOutsideBehavior::UnserializeFrom(const gd::SerializerElement & element)
{
    extraBorder = element.GetDoubleAttribute("extraBorder");
}
Esempio n. 12
0
void ParticleEmitterBase::UnserializeParticleEmitterBaseFrom(
    const gd::SerializerElement& element) {
  tank = element.GetDoubleAttribute("tank");
  flow = element.GetDoubleAttribute("flow");
  emitterForceMin = element.GetDoubleAttribute("emitterForceMin");
  emitterForceMax = element.GetDoubleAttribute("emitterForceMax");
  emitterXDirection = element.GetDoubleAttribute("emitterXDirection");
  emitterYDirection = element.GetDoubleAttribute("emitterYDirection");
  emitterZDirection = element.GetDoubleAttribute("emitterZDirection");
  emitterAngleA = element.GetDoubleAttribute("emitterAngleA");
  emitterAngleB = element.GetDoubleAttribute("emitterAngleB");
  zoneRadius = element.GetDoubleAttribute("zoneRadius");
  particleGravityX = element.GetDoubleAttribute("particleGravityX");
  particleGravityY = element.GetDoubleAttribute("particleGravityY");
  particleGravityZ = element.GetDoubleAttribute("particleGravityZ");
  friction = element.GetDoubleAttribute("friction");
  particleLifeTimeMin = element.GetDoubleAttribute("particleLifeTimeMin");
  particleLifeTimeMax = element.GetDoubleAttribute("particleLifeTimeMax");
  particleRed1 = element.GetDoubleAttribute("particleRed1");
  particleRed2 = element.GetDoubleAttribute("particleRed2");
  particleGreen1 = element.GetDoubleAttribute("particleGreen1");
  particleGreen2 = element.GetDoubleAttribute("particleGreen2");
  particleBlue1 = element.GetDoubleAttribute("particleBlue1");
  particleBlue2 = element.GetDoubleAttribute("particleBlue2");
  particleAlpha1 = element.GetDoubleAttribute("particleAlpha1");
  particleAlpha2 = element.GetDoubleAttribute("particleAlpha2");
  rendererParam1 = element.GetDoubleAttribute("rendererParam1");
  rendererParam2 = element.GetDoubleAttribute("rendererParam2");
  particleSize1 = element.GetDoubleAttribute("particleSize1");
  particleSize2 = element.GetDoubleAttribute("particleSize2");
  particleAngle1 = element.GetDoubleAttribute("particleAngle1");
  particleAngle2 = element.GetDoubleAttribute("particleAngle2");
  particleAlphaRandomness1 =
      element.GetDoubleAttribute("particleAlphaRandomness1");
  particleAlphaRandomness2 =
      element.GetDoubleAttribute("particleAlphaRandomness2");
  particleSizeRandomness1 =
      element.GetDoubleAttribute("particleSizeRandomness1");
  particleSizeRandomness2 =
      element.GetDoubleAttribute("particleSizeRandomness2");
  particleAngleRandomness1 =
      element.GetDoubleAttribute("particleAngleRandomness1");
  particleAngleRandomness2 =
      element.GetDoubleAttribute("particleAngleRandomness2");
  additive = element.GetBoolAttribute("additive");
  destroyWhenNoParticles =
      element.GetBoolAttribute("destroyWhenNoParticles", false);
  textureParticleName = element.GetStringAttribute("textureParticleName");
  maxParticleNb = element.GetIntAttribute("maxParticleNb", 5000);

  {
    gd::String result = element.GetStringAttribute("rendererType");
    if (result == "Line")
      rendererType = Line;
    else if (result == "Quad")
      rendererType = Quad;
    else
      rendererType = Point;
  }
  {
    gd::String result = element.GetStringAttribute("redParam");
    if (result == "Mutable")
      redParam = Mutable;
    else if (result == "Random")
      redParam = Random;
    else
      redParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("greenParam");
    if (result == "Mutable")
      greenParam = Mutable;
    else if (result == "Random")
      greenParam = Random;
    else
      greenParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("blueParam");
    if (result == "Mutable")
      blueParam = Mutable;
    else if (result == "Random")
      blueParam = Random;
    else
      blueParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("alphaParam");
    if (result == "Mutable")
      alphaParam = Mutable;
    else if (result == "Random")
      alphaParam = Random;
    else
      alphaParam = Enabled;
  }
  {
    gd::String result = element.GetStringAttribute("sizeParam");
    if (result == "Mutable")
      sizeParam = Mutable;
    else if (result == "Random")
      sizeParam = Random;
    else
      sizeParam = Nothing;
  }
  {
    gd::String result = element.GetStringAttribute("angleParam");
    if (result == "Mutable")
      angleParam = Mutable;
    else if (result == "Random")
      angleParam = Random;
    else
      angleParam = Nothing;
  }
}
Esempio n. 13
0
void OpenPoint(Point & point, const gd::SerializerElement & element)
{
    point.SetName(element.GetStringAttribute("name", "", "nom"));
    point.SetX(element.GetDoubleAttribute("x", 0, "X"));
    point.SetY(element.GetDoubleAttribute("y", 0, "Y"));
}