本文整理汇总了C++中HousePtr::state方法的典型用法代码示例。如果您正苦于以下问题:C++ HousePtr::state方法的具体用法?C++ HousePtr::state怎么用?C++ HousePtr::state使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HousePtr
的用法示例。
在下文中一共展示了HousePtr::state方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
void Sentiment::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>();
if( house.isValid() )
{
int happiness = math::clamp<int>( house->state( pr::happiness ) / maxSentimentLevel, 0, maxSentimentLevel-1 );
text = sentimentLevelName[ happiness ];
}
}
_setTooltipText( text );
}
break;
default: break;
}
}
Layer::handleEvent( event );
}
示例2: drawTile
void Fire::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 fireLevel = 0;
if( _isVisibleObject( overlay->type() ) )
{
// Base set of visible objects
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = ptr_cast<House>( overlay );
fireLevel = (int)house->state( pr::fire );
needDrawAnimations = (house->spec().level() == 1) && house->habitants().empty();
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::inHouseBase );
}
else //other buildings
{
ConstructionPtr constr = ptr_cast<Construction>( overlay );
if( constr != 0 )
{
fireLevel = (int)constr->state( pr::fire );
}
drawArea( engine, overlay->area(), offset, ResourceGroup::foodOverlay, OverlayPic::base );
}
if( needDrawAnimations )
{
Layer::drawTile( engine, tile, offset );
registerTileForRendering( tile );
}
else if( fireLevel >= 0)
{
_addColumn( screenPos, fireLevel );
}
}
tile.setWasDrawn();
}
示例3: _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;
}
示例4: drawTile
void Sentiment::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 sentimentLevel = 0;
if( _isVisibleObject( overlay->type() ) )
{
needDrawAnimations = true;
}
else if( overlay->type() == object::house )
{
HousePtr house = overlay.as<House>();
sentimentLevel = (int)house->state( pr::happiness );
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( sentimentLevel > 0 )
{
drawColumn( engine, screenPos, 100 - sentimentLevel );
}
}
tile.setWasDrawn();
}