当前位置: 首页>>代码示例>>C++>>正文


C++ PlayerCityPtr::addOverlay方法代码示例

本文整理汇总了C++中PlayerCityPtr::addOverlay方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerCityPtr::addOverlay方法的具体用法?C++ PlayerCityPtr::addOverlay怎么用?C++ PlayerCityPtr::addOverlay使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PlayerCityPtr的用法示例。


在下文中一共展示了PlayerCityPtr::addOverlay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: decodeTerrain

void LoaderHelper::decodeTerrain( Tile &oTile, PlayerCityPtr city, unsigned int forceId )
{
  int changeId = 0;
  unsigned int imgId = oTile.originalImgId();
  object::Type ovType = object::unknown;
  if( oTile.getFlag( Tile::tlRoad ) )   // road
  {
    ovType = object::road;
    Picture pic = MetaDataHolder::randomPicture( object::terrain, Size(1) );
    oTile.setPicture( pic );
    changeId = imgid::fromResource( pic.name() );
  }
  else if( oTile.getFlag( Tile::tlTree ) )
  {
    ovType = object::tree;
    Picture pic = MetaDataHolder::randomPicture( object::terrain, Size(1) );
    oTile.setPicture( pic );
    changeId = imgid::fromResource( pic.name() );
  }
  else if( oTile.getFlag( Tile::tlMeadow ) )
  {
    /*bool oldgfx = !SETTINGS_VALUE( c3gfx ).toString().empty();
    oldgfx |= SETTINGS_VALUE( oldgfx ).toBool();
    if( !oldgfx )
    {
      Picture pic = MetaDataHolder::randomPicture( objects::meadow, Size(1) );
      oTile.setPicture( pic );
      changeId = imgid::fromResource( pic.name() );
    }*/
  } 
  else if( imgId >= 0x29c && imgId <= 0x2a1 ) //aqueduct
  {
    ovType = object::aqueduct;
    Picture pic = MetaDataHolder::randomPicture( object::terrain, Size(1) );
    oTile.setPicture( pic );
    oTile.setFlag( Tile::clearAll, true );
    changeId = imgid::fromResource( pic.name() );
  }
  else if( imgId >= 372 && imgId <= 427 )
  {
    oTile.setFlag( Tile::tlCoast, true );
    if( imgId >= 388 )
      oTile.setFlag( Tile::tlRubble, true );
  }
  else if( imgId >= 863 && imgId <= 870 )
  {
    Picture pic = MetaDataHolder::randomPicture( object::terrain, Size(1) );
    oTile.setPicture( pic );
    oTile.setFlag( Tile::clearAll, true );    
    changeId = imgid::fromResource( pic.name() );
    oTile.setOriginalImgId( changeId );
  }
  else
  {
    unsigned id = forceId > 0 ? forceId : oTile.originalImgId();
    ovType = convImgId2ovrType( id );
  }

  if( ovType == object::unknown )
    return;

  OverlayPtr overlay; // This is the overlay object, if any
  overlay = TileOverlayFactory::instance().create( ovType );
  if( ovType == object::elevation )
  {
    std::string elevationPicName = imgid::toResource( oTile.originalImgId() );
    overlay->setPicture( Picture( elevationPicName ) );
  }

  if( overlay != NULL )
  {
    //Logger::warning( "Building at ( %d, %d ) with ID: %x", oTile.i(), oTile.j(), oTile.originalImgId() );
    if( oTile.overlay().isValid() )
      return;

    city::AreaInfo info( city, oTile.pos() );
    overlay->build( info );
    city->addOverlay( overlay );
  }  

  if( changeId > 0 )
  {
    oTile.setOriginalImgId( changeId );
  }
}
开发者ID:binakot,项目名称:caesaria-game,代码行数:85,代码来源:loaderhelper.cpp


注:本文中的PlayerCityPtr::addOverlay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。