本文整理汇总了C++中PlayerCityPtr类的典型用法代码示例。如果您正苦于以下问题:C++ PlayerCityPtr类的具体用法?C++ PlayerCityPtr怎么用?C++ PlayerCityPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlayerCityPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Level::Impl::initMainUI()
{
PlayerCityPtr city = game->city();
gui::Ui& ui = *game->gui();
ui.clear();
topMenu = &ui.add<TopMenu>(topMenuHeight, !city->getOption(PlayerCity::c3gameplay));
//bool fitToHeidht = OSystem::isAndroid();
//menu = Menu::create( ui.rootWidget(), -1, city, fitToHeidht );
//menu->hide();
WindowMessageStack::create( ui.rootWidget() );
if( KILLSWITCH( rightMenu ) )
{
//rightPanel->setSide( MenuRigthPanel::rightSide );
//menu->setSide( Menu::rightSide, rightPanel->lefttop() );
//extMenu->setSide( Menu::rightSide, rightPanel->lefttop() );
}
else
{
//rightPanel->setSide( MenuRigthPanel::leftSide );
//menu->setSide( Menu::leftSide, rightPanel->righttop() );
//extMenu->setSide( Menu::leftSide, rightPanel->righttop() );
}
}
示例2:
void HealthCare::Impl::updateReasons( PlayerCityPtr city )
{
int lvl = math::clamp<int>( value / (health::maxValue/health::levelNumber), 0, health::levelNumber-1 );
std::string mainReason = healthDescription[ lvl ];
int clinics_n = city->statistic().objects.count( object::clinic );
mainReason += clinics_n > 0 ? "_clinic##" : "##";
reasons << mainReason;
if( lvl > health::levelNumber / 3 )
{
for( int i=0; reasonsInfo[ i ].type != object::unknown; i++ )
{
object::TypeSet availableTypes;
availableTypes.insert( reasonsInfo[ i ].type );
HouseList housesWantEvolve = city->statistic().houses.ready4evolve( availableTypes );
if( housesWantEvolve.size() > 0 )
{
reasons << reasonsInfo[i].info;
}
}
}
}
示例3: initBuildOptions
void initBuildOptions(PlayerCityPtr city)
{
city::development::Options bopts;
bopts = city->buildOptions();
bopts.setGroupAvailable( city::development::all, true );
city->setBuildOptions( bopts );
}
示例4: __removeCorners
static void __removeCorners(Game& game )
{
PlayerCityPtr oCity = game.city();
Tilemap& oTilemap = oCity->tilemap();
unsigned int mapSize = oTilemap.size();
TilePos psAr[8] = { TilePos(0, 1), TilePos(-1, 1), TilePos(-1, 0), TilePos(-1, -1),
TilePos(0, -1), TilePos(1, -1), TilePos(1, 0), TilePos(1, 1)};
//check one water tiles
for( unsigned int i=0; i < mapSize; i++ )
for( unsigned int j=0; j < mapSize; j++ )
{
TilePos tpos = TilePos( i, j );
Tile& wtile = oTilemap.at( tpos );
if( wtile.originalImgId() == 0 ||
wtile.getFlag( Tile::tlWater ) || wtile.getFlag( Tile::tlDeepWater ) )
continue;
for( int k=0; k < 8; k++ )
{
Tile& t = oTilemap.at( tpos + psAr[k] );
bool isWater = ( t.getFlag( Tile::tlWater ) || t.getFlag( Tile::tlDeepWater ) );
if( isWater )
{
wtile.setFlag( Tile::clearAll, true );
wtile.setOriginalImgId( 0 );
wtile.setPicture( Picture() );
break;
}
}
}
}
示例5: calcVacantHouse
void Migration::Impl::createMigrationToCity( PlayerCityPtr city )
{
unsigned int vh = calcVacantHouse( city );
if( vh == 0 )
{
return;
}
EmigrantList migrants;
migrants << city->walkers();
if( vh <= migrants.size() * 5 )
{
return;
}
Tile& roadTile = city->tilemap().at( city->borderInfo().roadEntry );
ImmigrantPtr emigrant = Immigrant::create( city );
if( emigrant.isValid() )
{
bool success = emigrant->send2city( roadTile );
emigrant->setSpeedMultiplier( 0.8f + math::random( 40 ) / 100.f );
if( success )
lastMonthComing += emigrant->peoples().count();
}
}
示例6: _attackAny
void PlayerArmy::_reachedWay()
{
if( _d->mode == PlayerArmy::go2location )
{
_attackAny();
return2fort();
}
else if( _d->mode == PlayerArmy::go2home )
{
PlayerCityPtr pCity = ptr_cast<PlayerCity>( _d->base );
if( pCity.isValid() )
{
for( auto sldr : _d->soldiersInfo )
{
int type = sldr.save[ "type" ];
WalkerPtr walker = WalkerManager::instance().create( (walker::Type)type, pCity );
walker->load( sldr.save );
walker->attach();
}
auto fort = pCity->getOverlay( _d->fortPos ).as<Fort>();
if( fort.isValid() )
{
fort->returnSoldiers();
fort->resetExpedition();
}
}
deleteLater();
}
}
示例7: initialize
void Level::initialize()
{
PlayerCityPtr city = _d->game->city();
_d->initRender();
_d->initMainUI();
_d->installHandlers( this );
_d->initSound();
_d->initTabletUI( this );
_d->undoStack.init( city );
//connect elements
//city->tilemap().setFlag( Tilemap::fSvkGround, !KILLSWITCH(oldgfx) );
CONNECT( city, onWarningMessage(), _d.data(), Impl::resolveWarningMessage )
//CONNECT( _d->extMenu, onSelectOverlayType(), _d.data(), Impl::resolveSelectLayer )
CONNECT( city, onDisasterEvent(), &_d->alarmsHolder, AlarmEventHolder::add )
CONNECT( &_d->alarmsHolder, onMoveToAlarm(), _d->renderer.camera(), Camera::setCenter )
CONNECT( &_d->alarmsHolder, onAlarmChange(), _d.data(), Impl::setAlarmEnabled )
CONNECT( _d->renderer.camera(), onPositionChanged(), _d.data(), Impl::saveCameraPos )
CONNECT( _d->renderer.camera(), onDirectionChanged(), _d.data(), Impl::handleDirectionChange )
CONNECT( &_d->renderer, onLayerSwitch(), _d.data(), Impl::layerChangedOut )
CONNECT( &_d->undoStack, onUndoChange(), _d.data(), Impl::resolveUndoChange )
_d->renderer.camera()->setCenter(city->cameraPos());
_d->dhandler.insertTo(_d->game, _d->topMenu);
_d->dhandler.setVisible(false);
events::dispatch<events::ScriptFunc>("OnMissionStart");
}
示例8: TilePos
void C3Map::Impl::initCameraStartPos(std::fstream &f, PlayerCityPtr ioCity)
{
/*unsigned short int i = 0;
unsigned short int j = 0;
f.seekg(kCamera, std::ios::beg);
f.read((char*)&i, 2);
f.read((char*)&j, 2);*/
int mapSize = ioCity->tilemap().size();
ioCity->setCameraPos( TilePos( mapSize / 2, mapSize / 2 ) );
}
示例9: Variant
void PostponeEvent::Impl::executeCityService( Game& game, const std::string& type, bool& r )
{
PlayerCityPtr city = game.city();
std::string dtype = options.get( "type", Variant( type ) ).toString();
city::SrvcPtr srvc = city::ServiceFactory::create( game.city(), dtype );
if( srvc.isValid() )
{
srvc->load( options );
city->addService( srvc );
r = true;
return;
}
r = false;
}
示例10: _exec
void Notify::_exec(Game& game, unsigned int)
{
world::CityPtr pCity = game.empire()->findCity( _d->cityname );
PlayerCityPtr plrCity = ptr_cast<PlayerCity>( pCity );
if( plrCity.isValid() )
{
MilitaryPtr mil = plrCity->statistic().services.find<Military>();
if( mil.isValid() )
{
mil->addNotification( _d->message, _d->object, (Notification::Type)_d->type );
}
}
}
示例11: _computePictures
void LowBridge::_computePictures(PlayerCityPtr city, const TilePos& startPos, const TilePos& endPos, constants::Direction dir )
{
Tilemap& tilemap = city->tilemap();
//Picture& water = Picture::load( "land1a", 120 );
switch( dir )
{
case northWest:
{
TilesArray tiles = tilemap.getArea( endPos, startPos );
if (tiles.size() < 3) break;
tiles.pop_back();
tiles.erase( tiles.begin() );
_d->addSpan( tiles.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest );
foreach( it, tiles )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest );
}
_d->addSpan( tiles.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest );
}
break;
case northEast:
{
TilesArray tiles = tilemap.getArea( startPos, endPos );
if (tiles.size() < 3) break;
tiles.pop_back();
tiles.erase( tiles.begin() );
_d->addSpan( tiles.back()->pos() - startPos + TilePos( 0, 1 ), LowBridgeSubTile::liftingNorth );
for( TilesArray::reverse_iterator it=tiles.rbegin(); it != tiles.rend(); ++it )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanNorth );
}
_d->addSpan( tiles.front()->pos() - startPos - TilePos( 0, 1 ), LowBridgeSubTile::descentNorth );
}
break;
case southEast:
{
TilesArray tiles = tilemap.getArea( startPos, endPos );
if( tiles.size() < 3 )
break;
tiles.pop_back();
tiles.erase( tiles.begin() );
_d->addSpan( tiles.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest );
foreach( it, tiles )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest );
//_d->subtiles.push_back( LowBridgeSubTile( (*it)->getIJ() - startPos, water ) );
}
_d->addSpan( tiles.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest );
}
示例12: startPos
EmpirePricesWindow::EmpirePricesWindow(Widget *parent, int id, const Rect &rectangle, PlayerCityPtr city)
: Window( parent, rectangle, "", id )
{
setupUI( ":/gui/empireprices.gui" );
city::TradeOptions& ctrade = city->tradeOptions();
Font font = Font::create( FONT_1 );
Point startPos( 140, 50 );
for( int i=Good::wheat; i < Good::prettyWine; i++ )
{
if( i == Good::fish || i == Good::denaries)
{
continue;
}
Good::Type gtype = (Good::Type)i;
Picture goodIcon = GoodHelper::picture( gtype );
new Image( this, startPos, goodIcon );
std::string priceStr = StringHelper::format( 0xff, "%d", ctrade.buyPrice( gtype ) );
Label* lb = new Label( this, Rect( startPos + Point( 0, 34 ), Size( 24, 24 ) ), priceStr );
lb->setFont( font );
priceStr = StringHelper::format( 0xff, "%d", ctrade.sellPrice( gtype ) );
lb = new Label( this, Rect( startPos + Point( 0, 58 ), Size( 24, 24 ) ), priceStr );
lb->setFont( font );
startPos += Point( 30, 0 );
}
}
示例13:
void Migration::Impl::createMigrationFromCity( PlayerCityPtr city )
{
HouseList houses = city->statistic().houses.find();
const int minWorkersNumber = 4;
for( HouseList::iterator i=houses.begin(); i != houses.end(); )
{
int houseWorkless = (*i)->unemployed();
if( !(*i)->enterArea().empty() && houseWorkless > minWorkersNumber ) { ++i; }
else { i = houses.erase( i ); }
}
if( !houses.empty() )
{
int number = math::random( houses.size() );
HouseList randHouses = houses.random( number );
for( auto house : randHouses )
{
ImmigrantPtr emigrant = Immigrant::create( city );
if( emigrant.isValid() )
{
house->removeHabitants( minWorkersNumber );
emigrant->leaveCity( *(house->enterArea().front()) );
emigrant->setThinks( "##immigrant_no_work_for_me##" );
}
}
}
}
示例14: _removeGoodFrom
void _removeGoodFrom( PlayerCityPtr city, objects::Type btype, good::Product what, int& qty )
{
SmartList<T> bList;
#ifdef CAESARIA_PLATFORM_HAIKU
bList << city->overlays();
#else
city::Helper helper( city );
bList = helper.find<T>( btype );
#endif
foreach( it, bList )
{
if( qty <= 0 )
break;
good::Store& store = (*it)->store();
int maxQty = std::min( store.getMaxRetrieve( what ), qty );
if( maxQty > 0 )
{
good::Stock stock( what, maxQty );
store.retrieve( stock, maxQty );
qty -= maxQty;
}
}
}
示例15: _computePictures
void LowBridge::_computePictures(PlayerCityPtr city, const TilePos& startPos, const TilePos& endPos, Direction dir )
{
Tilemap& tilemap = city->tilemap();
//Picture& water = Picture::load( "land1a", 120 );
switch( dir )
{
case direction::northWest:
{
Bridge::Area area( tilemap, endPos, startPos );
if (area.size() < 3)
break;
area.cropCorners();
_d->addSpan( area.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest );
foreach( it, area )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest );
}
_d->addSpan( area.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest );
}
break;
case direction::northEast:
{
Bridge::Area area( tilemap, startPos, endPos );
if (area.size() < 3)
break;
area.cropCorners();
_d->addSpan( area.back()->pos() - startPos + TilePos( 0, 1 ), LowBridgeSubTile::liftingNorth );
for( TilesArray::reverse_iterator it=area.rbegin(); it != area.rend(); ++it )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanNorth );
}
_d->addSpan( area.front()->pos() - startPos - TilePos( 0, 1 ), LowBridgeSubTile::descentNorth );
}
break;
case direction::southEast:
{
Bridge::Area area( tilemap, startPos, endPos );
if( area.size() < 3 )
break;
area.cropCorners();
_d->addSpan( area.front()->pos() - startPos - TilePos( 1, 0 ), LowBridgeSubTile::liftingWest );
foreach( it, area )
{
_d->addSpan( (*it)->pos() - startPos, LowBridgeSubTile::spanWest );
}
_d->addSpan( area.back()->pos() - startPos + TilePos( 1, 0 ), LowBridgeSubTile::descentWest );
}