Exemple #1
0
/**
 * Destroy a part on this tile. We first remove the old object, then replace it with the destroyed one.
 * This is because the object type of the old and new one are not necessarily the same.
 * If the destroyed part is an explosive, set the tile's explosive value, which will trigger a chained explosion.
 * @param part
 * @return bool Return true objective was destroyed
 */
bool Tile::destroy(int part)
{
	bool _objective = false;
	if (_objects[part])
	{
		if (_objects[part]->isGravLift())
			return false;
		_objective = _objects[part]->getSpecialType() == MUST_DESTROY;
		MapData *originalPart = _objects[part];
		int originalMapDataSetID = _mapDataSetID[part];
		setMapData(0, -1, -1, part);
		if (originalPart->getDieMCD())
		{
			MapData *dead = originalPart->getDataset()->getObjects()->at(originalPart->getDieMCD());
			setMapData(dead, originalPart->getDieMCD(), originalMapDataSetID, dead->getObjectType());
		}
		if (originalPart->getExplosive())
		{
			setExplosive(originalPart->getExplosive());
		}
	}
	/* check if the floor on the lowest level is gone */
	if (part == MapData::O_FLOOR && getPosition().z == 0 && _objects[MapData::O_FLOOR] == 0)
	{
		/* replace with scorched earth */
		setMapData(MapDataSet::getScorchedEarthTile(), 1, 0, MapData::O_FLOOR);
	}
	return _objective;
}
Exemple #2
0
/**
 * Open a door on this tile.
 * @param part
 * @param unit
 * @param reserve
 * @return a value: 0(normal door), 1(ufo door) or -1 if no door opened or 3 if ufo door(=animated) is still opening 4 if not enough TUs
 */
int Tile::openDoor(int part, BattleUnit *unit, BattleActionType reserve)
{
	if (!_objects[part]) return -1;

	if (_objects[part]->isDoor())
	{
		if (unit && unit->getTimeUnits() < _objects[part]->getTUCost(unit->getArmor()->getMovementType()) + unit->getActionTUs(reserve, unit->getMainHandWeapon(false)))
			return 4;
		if (_unit && _unit != unit && _unit->getPosition() != getPosition())
			return -1;
		setMapData(_objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD()), _objects[part]->getAltMCD(), _mapDataSetID[part],
				   _objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD())->getObjectType());
		setMapData(0, -1, -1, part);
		return 0;
	}
	if (_objects[part]->isUFODoor() && _currentFrame[part] == 0) // ufo door part 0 - door is closed
	{
		if (unit &&	unit->getTimeUnits() < _objects[part]->getTUCost(unit->getArmor()->getMovementType()) + unit->getActionTUs(reserve, unit->getMainHandWeapon(false)))
			return 4;
		_currentFrame[part] = 1; // start opening door
		return 1;
	}
	if (_objects[part]->isUFODoor() && _currentFrame[part] != 7) // ufo door != part 7 - door is still opening
	{
		return 3;
	}
	return -1;
}
Exemple #3
0
/**
 * Open a door on this tile.
 * @param part
 * @param unit
 * @param reserve
 * @return a value: 0(normal door), 1(ufo door) or -1 if no door opened or 3 if ufo door(=animated) is still opening 4 if not enough TUs
 */
int Tile::openDoor(TilePart part, BattleUnit *unit, BattleActionType reserve)
{
	if (!_objects[part]) return -1;

	BattleActionCost cost;
	if (unit)
	{
		int tuCost = _objects[part]->getTUCost(unit->getMovementType());
		cost = BattleActionCost(reserve, unit, unit->getMainHandWeapon(false));
		cost.Time += tuCost;
		cost.Energy += tuCost / 2;
	}

	if (_objects[part]->isDoor() && unit->getArmor()->getSize() == 1) // don't allow double-wide units to open swinging doors due to engine limitations
	{
		if (unit && cost.Time && !cost.haveTU())
			return 4;
		if (_unit && _unit != unit && _unit->getPosition() != getPosition())
			return -1;
		setMapData(_objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD()), _objects[part]->getAltMCD(), _mapDataSetID[part],
				   _objects[part]->getDataset()->getObjects()->at(_objects[part]->getAltMCD())->getObjectType());
		setMapData(0, -1, -1, part);
		return 0;
	}
	if (_objects[part]->isUFODoor() && _currentFrame[part] == 0) // ufo door part 0 - door is closed
	{
		if (unit && cost.Time && !cost.haveTU())
			return 4;
		_currentFrame[part] = 1; // start opening door
		return 1;
	}
	if (_objects[part]->isUFODoor() && _currentFrame[part] != 7) // ufo door != part 7 - door is still opening
	{
		return 3;
	}
	return -1;
}
Exemple #4
0
QTM_BEGIN_NAMESPACE

/*!
    \class QGeoMapObject
    \brief The QGeoMapObject class is a graphical item to be displayed on a map.
    \inmodule QtLocation
    \since 1.1

    \ingroup maps-mapping-objects

    QGeoMapObject is the base class used to display graphical items on a map.

    Subclasses of QGeoMapObject exist in order to simplify the task of
    creating and managing map objects of various kinds.

    QGeoMapCustomObject is the most generic of these objects in that it
    allows QGraphicsItems to be added to a map, however as not all mapping
    plugins use the Qt Graphics View framework so clients should use
    QGraphicsGeoMap::supportsCustomMapObjects() before using
    QGeoMapCustomObject.

    QGeoMapObject instances can also be grouped into heirarchies in order to
    simplify the process of creating compound objects and managing groups of
    objects (see QGeoMapGroupObject)
*/

/*!
    \enum QGeoMapObject::Type

    Describes the type of a map object.

    \value NullType
        An empty QGeoMapObject.
    \value GroupType
        A QGeoMapObject used to organize other map objects into groups.
    \value RectangleType
        A QGeoMapObject used to display a rectangular region.
    \value CircleType
        A QGeoMapObject used to display a circular region.
    \value PolylineType
        A QGeoMapObject used to display a multi-segment line.
    \value PolygonType
        A QGeoMapObject used to display a polygonal region.
    \value PixmapType
        A QGeoMapObject used to display a pixmap on a map.
    \value TextType
        A QGeoMapObject used to display text on a map
    \value RouteType
        A QGeoMapObject used to display a route.
    \value CustomType
        A QGeoMapObject displaying a custom GraphicsItem.
*/

/*!
    \enum QGeoMapObject::CoordinateUnit

    \since 1.2

    Describes the units of measurement used for a map object's
    graphics item.

    \value PixelUnit
        Units are in pixels on the screen. Pixel coordinate (0,0) is
        translated to the origin coordinate.
    \value MeterUnit
        Units are in meters on the ground -- a local Transverse Mercator
        coordinate system (on the WGS84 ellipsoid) is used for translation,
        centered on the origin coordinate.
    \value RelativeArcSecondUnit
        Units are in arc seconds relative to the origin coordinate (along the
        WGS84 ellipsoid).
    \value AbsoluteArcSecondUnit
        Units are in arc seconds on WGS84, origin ignored.
*/

/*!
    \enum QGeoMapObject::TransformType

    \since 1.2

    Describes the type of transformation applied to change this object's
    coordinate system into screen coordinates.

    \value BilinearTransform
        This object's bounding box is taken, and transformed at each of its
        corners into screen coordinates. A bilinear interpolation is then used
        to draw the rest of the object's GraphicsItem.
    \value ExactTransform
        Individual key points on the object are transformed and the GraphicsItem
        is constructed in direct pixel coordinates. This is only available for
        certain subclasses, depending on the implementation of QGeoMapData used.
*/

/*!
    Constructs a new map object associated with \a mapData.

    The object will be in pixel coordinates, with exact transform.
*/
QGeoMapObject::QGeoMapObject(QGeoMapData *mapData)
    : d_ptr(new QGeoMapObjectPrivate())
{
    setMapData(mapData);
}
Exemple #5
0
/*!
    Destroys this map object.
*/
QGeoMapObject::~QGeoMapObject()
{
    setMapData(0);
    delete d_ptr;
}