Пример #1
0
/*
The highest level where members are created. From here the map, tilesets,
layer/imagelayer, and object group/layer are read. Even though the element map
is the highest level it is treated as the same level as the other members.

@param root the beginning of the .tmx file.
@return void
*/
void TMXLoader::Initialize(tinyxml2::XMLNode* root) {
  tinyxml2::XMLElement* mapElement = root->NextSiblingElement();

  // Map.
  map = GetMap(mapElement);

  tinyxml2::XMLElement* mapChild = mapElement->FirstChildElement();
  while (mapChild) {
    // Map child is a tileset.
    if (strcmp(mapChild->Name(), "tileset") == tinyxml2::XML_SUCCESS) {
      tilesets.push_back(GetTileset(mapChild));
    }
    // Map child is a layer or imagelayer.
    else if (strcmp(mapChild->Name(), "layer") == tinyxml2::XML_SUCCESS ||
      strcmp(mapChild->Name(), "imagelayer") == tinyxml2::XML_SUCCESS) {
      layers.push_back(GetLayer(mapChild));
    }
    // Map child is an object-group/layer.
    else if (strcmp(mapChild->Name(), "objectgroup") == tinyxml2::XML_SUCCESS) {
      objectLayers.push_back(GetObjectLayer(mapChild));
    }

    mapChild = mapChild->NextSiblingElement();
  }
}
Пример #2
0
// documented in /docs/sdk/script/fn
global func Explode(int level, bool silent, int damage_level)
{
	if(!this) FatalError("Function Explode must be called from object context");
	
	// Special: Implode
	if (level <= 0) return RemoveObject();

	// Shake the viewport.
	ShakeViewport(level);
	
	// Explosion parameters.
	var x = GetX(), y = GetY();
	var cause_plr = GetController();
	var container = Contained();
	var exploding_id = GetID();
	var layer = GetObjectLayer();

	// Explosion parameters saved: Remove object now, since it should not be involved in the explosion.
	RemoveObject();

	// Execute the explosion in global context.
	// There is no possibility to interact with the global context, apart from GameCall.
	// So at least remove the object context.
	exploding_id->DoExplosion(x, y, level, container, cause_plr, layer, silent, damage_level);
}
Пример #3
0
global func BlueExplode(int level)
{
	// Shake the viewport.
	ShakeViewport(level, GetX(), GetY());

	// Sound must be created before object removal, for it to be played at the right position.
	var grade = BoundBy(level / 10 - 1, 1, 3);
	Sound(Format("Blast%d", grade), false);

	// Explosion parameters.
	var x = GetX(), y = GetY();
	var cause_plr = GetController();
	var container = Contained();
	var exploding_id = GetID();
	var layer = GetObjectLayer();

	// Explosion parameters saved: Remove object now, since it should not be involved in the explosion.
	RemoveObject();

	// Execute the explosion in global context.
	// There is no possibility to interact with the global context, apart from GameCall.
	// So at least remove the object context.
	exploding_id->DoBlueExplosion(x, y, level, container, cause_plr, layer);
	return;
}