本文整理汇总了C++中HousePtr::getServiceValue方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::getServiceValue方法的具体用法?C++ HousePtr::getServiceValue怎么用?C++ HousePtr::getServiceValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::getServiceValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawTile
void Religion::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
int religionLevel = -1;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = ptr_cast<House>( overlay );
religionLevel = (int) house->getServiceValue(Service::religionMercury);
religionLevel += house->getServiceValue(Service::religionVenus);
religionLevel += house->getServiceValue(Service::religionMars);
religionLevel += house->getServiceValue(Service::religionNeptune);
religionLevel += house->getServiceValue(Service::religionCeres);
religionLevel = math::clamp( religionLevel / (house->spec().minReligionLevel()+1), 0, 100 );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( religionLevel > 0 )
{
drawColumn( engine, screenPos, religionLevel );
}
}
tile.setWasDrawn();
}
示例2: _getLevelValue
int LayerHealth::_getLevelValue( HousePtr house )
{
switch(_type)
{
case citylayer::health: return (int) house->state( House::health );
case citylayer::hospital: return (int) house->getServiceValue( Service::hospital );
case citylayer::barber: return (int) house->getServiceValue( Service::barber );
case citylayer::baths: return (int) house->getServiceValue( Service::baths );
}
return 0;
}
示例3: handleEvent
void MarketAccess::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = tile->overlay<House>();
if( house.isValid() )
{
int accessLevel = house->getServiceValue( Service::market );
accessLevel = math::clamp<int>( accessLevel / maxAccessLevel, 0, maxAccessLevel-1 );
text = marketLevelName[ accessLevel ];
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例4: drawTile
void Unemployed::drawTile(Engine& engine, Tile& tile, const Point& offset)
{
Point screenPos = tile.mappos() + offset;
if( tile.overlay().isNull() )
{
//draw background
//engine.draw( tile.picture(), screenPos );
drawPass( engine, tile, offset, Renderer::ground );
drawPass( engine, tile, offset, Renderer::groundAnimation );
}
else
{
bool needDrawAnimations = false;
OverlayPtr overlay = tile.overlay();
WorkingBuildingPtr workBuilding = overlay.as<WorkingBuilding>();
int worklessPercent = 0;
if( _isVisibleObject( overlay->type() ) )
{
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = overlay.as<House>();
int worklessNumber = (int)house->getServiceValue( Service::recruter );
int matureNumber = (int)house->habitants().mature_n();
worklessPercent = math::percentage( worklessNumber, matureNumber );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
if( !needDrawAnimations )
{
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
}
else if( workBuilding.isValid() )
{
worklessPercent = math::percentage( workBuilding->needWorkers(), workBuilding->maximumWorkers() );
needDrawAnimations = workBuilding->needWorkers() > 0;
if( !needDrawAnimations )
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( worklessPercent > 0 )
{
drawColumn( engine, screenPos, worklessPercent );
}
}
tile.setWasDrawn();
}
示例5: _getLevelValue
int Entertainment::_getLevelValue( HousePtr house )
{
switch( _type )
{
case citylayer::entertainment:
{
int entLevel = house->spec().computeEntertainmentLevel( house );
int minLevel = house->spec().minEntertainmentLevel();
return math::percentage( entLevel, minLevel );
}
case citylayer::theater: return (int) house->getServiceValue( Service::theater );
case citylayer::amphitheater: return (int) house->getServiceValue( Service::amphitheater );
case citylayer::colloseum: return (int) house->getServiceValue( Service::colloseum );
case citylayer::hippodrome: return (int) house->getServiceValue( Service::hippodrome );
}
return 0;
}
示例6: _getLevelValue
int Education::_getLevelValue( HousePtr house ) const
{
switch(_type)
{
case citylayer::education:
{
float acc = 0;
int level = house->spec().minEducationLevel();
switch(level)
{
case 3:
acc += house->getServiceValue( Service::academy );
case 2:
acc += house->getServiceValue( Service::library );
case 1:
acc += house->getServiceValue( Service::school );
return static_cast<int>(acc / level);
default:
return 0;
}
}
case citylayer::school:
return (int) house->getServiceValue( Service::school );
case citylayer::library:
return (int) house->getServiceValue( Service::library );
case citylayer::academy:
return (int) house->getServiceValue( Service::academy );
}
return 0;
}
示例7: handleEvent
void Unemployed::handleEvent(NEvent& event)
{
if( event.EventType == sEventMouse )
{
switch( event.mouse.type )
{
case mouseMoved:
{
Tile* tile = _camera()->at( event.mouse.pos(), false ); // tile under the cursor (or NULL)
std::string text = "";
if( tile != 0 )
{
HousePtr house = tile->overlay().as<House>();
WorkingBuildingPtr workBuilding = tile->overlay().as<WorkingBuilding>();
if( house.isValid() )
{
int workless = house->getServiceValue( Service::recruter );
if( workless > 0 )
text = utils::format( 0xff, "%s %d %s", _("##this_house_have##"), workless, _("##unemployers##") );
else
text = "##this_house_haveno_unemployers##";
}
else if( workBuilding.isValid() )
{
int need = workBuilding->needWorkers();
if( need > 0 )
text = utils::format( 0xff, "%s %d %s", _("##this_building_need##"), need, _("##workers##") );
else
text = "##this_building_have_all_workers##";
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例8: if
void Disorder::Impl::weekUpdate( unsigned int time, PlayerCityPtr rcity )
{
HouseList houses = rcity->statistic().houses.find();
const WalkerList& walkers = rcity->statistic().walkers.find( walker::protestor );
HouseList criminalizedHouse;
crime.level.current = 0;
crime.level.maximum = 0;
for( auto house : houses )
{
int currentValue = house->getServiceValue( Service::crime )+1;
if( currentValue >= crime.level.minimum )
{
criminalizedHouse.push_back( house );
}
crime.level.current += currentValue;
crime.level.maximum = std::max<int>( crime.level.maximum, currentValue );
}
if( houses.size() > 0 )
crime.level.current /= houses.size();
if( criminalizedHouse.size() > walkers.size() )
{
HousePtr house = criminalizedHouse.random();
int hCrimeLevel = house->getServiceValue( Service::crime );
int sentiment = rcity->sentiment();
int randomValue = math::random( crime::maxValue );
if (sentiment >= minSentiment4protest )
{
if ( randomValue >= sentiment + 20 )
{
if ( hCrimeLevel > crime::level4protestor )
{
generateProtestor( rcity, house );
}
}
}
else if ( sentiment >= minSentiment4mugger )
{
if ( randomValue >= sentiment + 40 )
{
if ( hCrimeLevel >= crime::level4mugger )
{
generateMugger( rcity, house );
}
else if ( hCrimeLevel > crime::level4protestor )
{
generateProtestor( rcity, house );
}
}
}
else if( sentiment < minSentiment4mugger )
{
if ( randomValue >= sentiment + 50 )
{
if ( hCrimeLevel >= crime::level4rioter ) { generateRioter( rcity, house ); }
else if ( hCrimeLevel >= crime::level4mugger ) { generateMugger( rcity, house ); }
else if ( hCrimeLevel > crime::level4protestor ) { generateProtestor( rcity, house ); }
}
}
}
}
示例9: drawTile
void LayerHealth::drawTile(GfxEngine& engine, Tile& tile, Point offset)
{
Point screenPos = tile.getXY() + offset;
tile.setWasDrawn();
bool needDrawAnimations = false;
if( tile.getOverlay().isNull() )
{
//draw background
engine.drawPicture( tile.getPicture(), screenPos );
}
else
{
TileOverlayPtr overlay = tile.getOverlay();
int healthLevel = -1;
switch( overlay->getType() )
{
//fire buildings and roads
case construction::road:
case construction::B_PLAZA:
needDrawAnimations = true;
engine.drawPicture( tile.getPicture(), screenPos );
break;
case building::B_DOCTOR:
case building::B_HOSPITAL:
case building::B_BARBER:
case building::B_BATHS:
needDrawAnimations = _flags.count( overlay->getType() );
if( needDrawAnimations )
{
engine.drawPicture( tile.getPicture(), screenPos );
}
else
{
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
//houses
case building::house:
{
HousePtr house = overlay.as< House >();
if( _flags.count( building::B_DOCTOR ) ) { healthLevel = house->getHealthLevel(); }
else if( _flags.count( building::B_HOSPITAL ) ) { healthLevel = house->getServiceValue( Service::hospital ); }
else if( _flags.count( building::B_BARBER ) ) { healthLevel = house->getServiceValue( Service::barber ); }
else if( _flags.count( building::B_BATHS ) ) { healthLevel = house->getServiceValue( Service::baths ); }
needDrawAnimations = (house->getSpec().getLevel() == 1) && (house->getHabitants().size() == 0);
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
break;
//other buildings
default:
{
CityHelper helper( _city );
drawArea( engine, helper.getArea( overlay ), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
break;
}
if( needDrawAnimations )
{
_renderer->registerTileForRendering( tile );
}
else if( healthLevel > 0 )
{
drawColumn( engine, screenPos, 9, healthLevel );
}
}
}