本文整理汇总了C++中TilePos类的典型用法代码示例。如果您正苦于以下问题:C++ TilePos类的具体用法?C++ TilePos怎么用?C++ TilePos使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TilePos类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: offset
inline Pathway Statistic::_Walkers::freeTile( TilePos target, TilePos currentPos, const int range ) const
{
for( int currentRange=1; currentRange <= range; currentRange++ )
{
TilePos offset( currentRange, currentRange );
gfx::TilesArray tiles = _parent.map.perimetr( currentPos - offset, currentPos + offset );
tiles = tiles.walkables( true );
float crntDistance = target.distanceFrom( currentPos );
for( auto tile : tiles )
{
SmartList<T> eslist = _parent.rcity.walkers( tile->pos() ).select<T>();
if( !eslist.empty() )
continue;
if( target.distanceFrom( tile->pos() ) > crntDistance )
continue;
Pathway pathway = PathwayHelper::create( currentPos, tile->pos(), PathwayHelper::allTerrain );
if( pathway.isValid() )
{
return pathway;
}
}
}
return Pathway();
}
开发者ID:andrelago13,项目名称:caesaria-game,代码行数:29,代码来源:statistic.hpp
示例2:
TileTopBlockIterator::TileTopBlockIterator(const TilePos& tile, int block_size,
int tile_width)
: block_size(block_size), is_end(false) {
// at first get the chunk, whose row and column is at the top right of the tile
mc::ChunkPos topright_chunk = mc::ChunkPos::byRowCol(4 * tile_width * tile.getY(),
2 * tile_width * tile.getX() + 2);
// now get the first visible block from this chunk in this tile
top = mc::LocalBlockPos(8, 6, mc::CHUNK_HEIGHT * 16 - 1).toGlobalPos(topright_chunk);
// and set this as start
current = top;
// calculate bounds of the tile
min_row = top.getRow() + 1;
max_row = top.getRow() + (64 * tile_width) + 4;
max_col = top.getCol() + 2;
min_col = max_col - (32 * tile_width);
// calculate position of the first block, relative row/col in this tile are needed
int row = current.getRow() - min_row;
int col = current.getCol() - min_col;
// every column is a 1/2 block and every row is a 1/4 block
draw_x = col * block_size / 2;
// -1/2 blocksize, because we would see the top side of the blocks in the tile if not
draw_y = row * block_size / 4 - block_size / 2; // -16
}
开发者ID:aigamedev,项目名称:mapcrafter,代码行数:26,代码来源:tilerenderer.cpp
示例3: fit
TilePos Tilemap::fit( const TilePos& pos ) const
{
TilePos ret;
ret.setI( math::clamp( pos.i(), 0, _d->size ) );
ret.setJ( math::clamp( pos.j(), 0, _d->size ) );
return ret;
}
开发者ID:KSLcom,项目名称:caesaria-game,代码行数:7,代码来源:tilemap.cpp
示例4: helper
void WorkingBuilding::timeStep( const unsigned long time )
{
Building::timeStep( time );
for( WalkerList::iterator it=_d->walkerList.begin(); it != _d->walkerList.end(); )
{
if( (*it)->isDeleted() ) { it = _d->walkerList.erase( it ); }
else { ++it; }
}
if( game::Date::isMonthChanged() && numberWorkers() > 0 )
{
city::Helper helper( _city() );
TilePos offset( 8, 8 );
TilePos myPos = pos();
HouseList houses = helper.find<House>( objects::house, myPos - offset, myPos + offset );
float averageDistance = 0;
foreach( it, houses )
{
if( (*it)->spec().level() < HouseLevel::smallVilla )
{
averageDistance += myPos.distanceFrom( (*it)->pos() );
}
}
if( houses.size() > 0 )
averageDistance /= houses.size();
_d->laborAccessKoeff = math::clamp( math::percentage( averageDistance, 8 ) * 2, 25, 100 );
}
开发者ID:KSLcom,项目名称:caesaria-game,代码行数:30,代码来源:working.cpp
示例5: foreach
foreach( it, buildings )
{
if( (*it)->type() == object::house )
{
HousePtr house = it->as<House>();
TilePos pos = house->pos();
int hash = (pos.i() << 8) | pos.i();
_d->servedHouses[ hash ] = house->habitants().count();
}
}
开发者ID:Ecordonnier,项目名称:caesaria-game,代码行数:10,代码来源:health.cpp
示例6: renderTile
void TopdownTileRenderer::renderTile(const TilePos& tile_pos, RGBAImage& tile) {
int texture_size = images->getTextureSize();
tile.setSize(getTileSize(), getTileSize());
for (int x = 0; x < tile_width; x++) {
for (int z = 0; z < tile_width; z++) {
mc::ChunkPos chunkpos(tile_pos.getX() * tile_width + x, tile_pos.getY() * tile_width + z);
current_chunk = world->getChunk(chunkpos);
if (current_chunk != nullptr)
renderChunk(*current_chunk, tile, texture_size*16*x, texture_size*16*z);
}
}
}
开发者ID:aigamedev,项目名称:mapcrafter,代码行数:13,代码来源:tilerenderer.cpp
示例7: TilePos
std::list<Tile*> Tilemap::getFilledRectangle(const TilePos& start, const TilePos& stop )
{
std::list<Tile*> res;
for (int i = start.getI(); i <= stop.getI(); ++i)
{
for (int j = start.getJ(); j <= stop.getJ(); ++j)
{
if( is_inside( TilePos( i, j ) ))
{
res.push_back(&at( TilePos( i, j ) ) );
}
}
}
return res;
}
开发者ID:DarkLotus,项目名称:opencaesar3,代码行数:17,代码来源:oc3_tilemap.cpp
示例8: __D_IMPL
TilesArray Layer::_getSelectedArea( TilePos startPos )
{
__D_IMPL(_d,Layer)
TilePos outStartPos, outStopPos;
Tile* startTile = startPos.i() < 0
? _d->camera->at( _d->startCursorPos, true ) // tile under the cursor (or NULL)
: _d->camera->at( startPos );
Tile* stopTile = _d->camera->at( _d->lastCursorPos, true );
TilePos startPosTmp = startTile->epos();
TilePos stopPosTmp = stopTile->epos();
outStartPos = TilePos( std::min<int>( startPosTmp.i(), stopPosTmp.i() ), std::min<int>( startPosTmp.j(), stopPosTmp.j() ) );
outStopPos = TilePos( std::max<int>( startPosTmp.i(), stopPosTmp.i() ), std::max<int>( startPosTmp.j(), stopPosTmp.j() ) );
return _city()->tilemap().getArea( outStartPos, outStopPos );
}
开发者ID:KSLcom,项目名称:caesaria-game,代码行数:18,代码来源:layer.cpp
示例9: MapTile
WarpTile::WarpTile(TilePos pos, PlayfieldInfo *pfi) : MapTile(pos), holePixmap(this) {
targetTile = 0;
playfield = pfi;
holeOpen = true;
QTransform tf;
if(pos.x() > MAPW/2)
tf.scale(-1,1);
holePixmap.setPixmap(Sprite::loadBitmap("wow-sprites/warphole.bmp", 2).transformed(tf));
connect(&closedTimer, SIGNAL(timeout()), this, SLOT(reopen()));
}
开发者ID:vranki,项目名称:Warriors-of-Wor,代码行数:10,代码来源:warptile.cpp
示例10: getPoint
std::list<AStarPoint*> Pathfinder::getTraversingPoints( const TilePos& start, const TilePos& stop )
{
std::list<AStarPoint*> points;
if( start == stop )
return points;
points.push_back( getPoint( start ) );
TilePos housePos = stop;
while( points.back()->getPos() != housePos )
{
TilePos ij = points.back()->getPos();
TilePos move( math::clamp( housePos.getI() - ij.getI(), -1, 1 ), math::clamp( housePos.getJ() - ij.getJ(), -1, 1 ) );
points.push_back( getPoint( ij + move ) );
}
return points;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:19,代码来源:oc3_astarpathfinding.cpp
示例11: setPicture
void Garden::build( CityPtr city, const TilePos& pos )
{
// this is the same arrangement of garden tiles as existed in C3
int theGrid[2][2] = {{113, 110}, {112, 111}};
Construction::build( city, pos );
setPicture( ResourceGroup::entertaiment, theGrid[pos.getI() % 2][pos.getJ() % 2] );
if( getSize().getArea() == 1 )
{
TilemapTiles tilesAround = city->getTilemap().getRectangle( getTilePos() - TilePos( 1, 1),
getTilePos() + TilePos( 1, 1 ) );
foreach( Tile* tile, tilesAround )
{
GardenPtr garden = tile->getOverlay().as<Garden>();
if( garden.isValid() )
{
garden->update();
}
}
开发者ID:brobits,项目名称:opencaesar3,代码行数:20,代码来源:garden.cpp
示例12: getGScore
int getGScore(AStarPoint* p)
{
int offset = p->tile->get_terrain().isRoad() ? -5 : +10;
TilePos pos = tile ? tile->getIJ() : TilePos( 0, 0 );
TilePos otherPos = p->tile->getIJ();
return p->g + ((pos.getI() == otherPos.getI() || pos.getJ() == otherPos.getJ()) ? 10 : 14) + offset;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:7,代码来源:oc3_astarpoint.hpp
示例13: TilePos
/* INCORRECT! */
bool Wharf::canBuild(const TilePos& pos ) const
{
bool is_constructible = Construction::canBuild( pos );
// We can build wharf only on straight border of water and land
//
// ?WW? ???? ???? ????
// ?XX? WXX? ?XXW ?XX?
// ?XX? WXX? ?XXW ?XX?
// ???? ???? ???? ?WW?
//
bool bNorth = true;
bool bSouth = true;
bool bWest = true;
bool bEast = true;
Tilemap& tilemap = Scenario::instance().getCity().getTilemap();
std::list<Tile*> rect = tilemap.getRectangle( pos + TilePos( -1, -1 ), Size( _size+2 ), false);
for (std::list<Tile*>::iterator itTiles = rect.begin(); itTiles != rect.end(); ++itTiles)
{
Tile &tile = **itTiles;
std::cout << tile.getI() << " " << tile.getJ() << " " << pos.getI() << " " << pos.getJ() << std::endl;
// if (tiles.get_terrain().isWater())
if (tile.getJ() > (pos.getJ() + _size -1) && !tile.get_terrain().isWater()) { bNorth = false; }
if (tile.getJ() < pos.getJ() && !tile.get_terrain().isWater()) { bSouth = false; }
if (tile.getI() > (pos.getI() + _size -1) && !tile.get_terrain().isWater()) { bEast = false; }
if (tile.getI() < pos.getI() && !tile.get_terrain().isWater()) { bWest = false; }
}
return (is_constructible && (bNorth || bSouth || bEast || bWest));
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:36,代码来源:oc3_factory_building.cpp
示例14: offset
int Statistic::_Objects::laborAccess(WorkingBuildingPtr wb) const
{
if( wb.isNull() )
return 0;
TilePos offset( maxLaborDistance, maxLaborDistance );
TilePos wbpos = wb->pos();
HouseList houses = find<House>( object::house, wbpos - offset, wbpos + offset );
float averageDistance = 0;
for( auto house : houses )
{
if( house->level() > HouseLevel::vacantLot
&& house->level() < HouseLevel::smallVilla )
{
averageDistance += wbpos.distanceFrom( house->pos() );
}
}
if( houses.size() > 0 )
averageDistance /= houses.size();
return math::clamp( math::percentage( averageDistance, maxLaborDistance ) * 2, 25, 100 );
}
开发者ID:andrelago13,项目名称:caesaria-game,代码行数:23,代码来源:statistic.cpp
示例15: helper
Pathway FishingBoat::Impl::findFishingPlace(PlayerCityPtr city, TilePos pos )
{
city::Helper helper( city );
FishPlaceList places = helper.find<FishPlace>( walker::fishPlace, city::Helper::invalidPos );
int minDistance = 999;
FishPlacePtr nearest;
foreach( it, places )
{
FishPlacePtr place = *it;
int currentDistance = pos.distanceFrom( place->pos() );
if( currentDistance < minDistance )
{
minDistance = currentDistance;
nearest = place;
}
}
开发者ID:KSLcom,项目名称:caesaria-game,代码行数:17,代码来源:fishing_boat.cpp
示例16: _brokePathway
void CartPusher::_brokePathway(TilePos pos)
{
_d->brokePathCounter++;
if( _pathway().isValid() && _d->brokePathCounter < 5 )
{
Pathway way = PathwayHelper::create( pos, _pathway().stopPos(), PathwayHelper::roadFirst );
if( way.isValid() )
{
setPathway( way );
go();
return;
}
}
Logger::warning( "CartPusher::_brokePathway not destination point [%d,%d]", pos.i(), pos.j() );
deleteLater();
}
开发者ID:binakot,项目名称:caesaria-game,代码行数:17,代码来源:cart_pusher.cpp
示例17: r
// Get tiles inside of rectangle
TilesArray Tilemap::getArea(const TilePos& start, const TilePos& stop ) const
{
TilesArray res;
int expected = math::min((abs(stop.i() - start.i()) + 1) * (abs(stop.j() - start.j()) + 1), 100);
res.reserve(expected);
Rect r( start.i(), start.j(), stop.i(), stop.j() );
r.repair();
for (int i = r.left(); i <= r.right(); ++i)
{
for (int j = r.top(); j <= r.bottom(); ++j)
{
if( isInside( TilePos( i, j ) ))
{
res.push_back( &( const_cast<Tilemap*>( this )->at( TilePos( i, j ) )) );
}
}
}
return res;
}
开发者ID:KSLcom,项目名称:caesaria-game,代码行数:23,代码来源:tilemap.cpp
示例18: getHScore
int getHScore(AStarPoint* p)
{
TilePos pos = tile ? tile->getIJ() : TilePos( 0, 0 );
TilePos otherPos = p->tile->getIJ();
return (abs(otherPos.getI() - pos.getI()) + abs(otherPos.getJ() - pos.getJ())) * 10;
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:6,代码来源:oc3_astarpoint.hpp
示例19: pointIsWalkable
bool Pathfinder::pointIsWalkable( const TilePos& pos )
{
return (pointExists( pos ) && grid[ pos.getI() ][ pos.getJ() ]->isWalkable() );
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:4,代码来源:oc3_astarpathfinding.cpp
示例20: pointExists
bool Pathfinder::pointExists( const TilePos& pos )
{
return ( pos.getI() < grid.size() && pos.getJ() < grid[pos.getI()].size() );
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:4,代码来源:oc3_astarpathfinding.cpp
注:本文中的TilePos类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论