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


C++ TilePos函数代码示例

本文整理汇总了C++中TilePos函数的典型用法代码示例。如果您正苦于以下问题:C++ TilePos函数的具体用法?C++ TilePos怎么用?C++ TilePos使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _d

CartSupplier::CartSupplier( CityPtr city ) : _d( new Impl )
{
   _walkerGraphic = WG_PUSHER;
   _walkerType = WT_CART_PUSHER;
   _d->storageBuildingPos = TilePos( -1, -1 );
   _d->baseBuildingPos = TilePos( -1, -1 );
   _d->maxDistance = 25;
   _d->city = city;
}
开发者ID:nickers,项目名称:opencaesar3,代码行数:9,代码来源:oc3_walker_cart_supplier.cpp

示例2: Walker

CartSupplier::CartSupplier( CityPtr city )
  : Walker( city ), _d( new Impl )
{
  _setGraphic( WG_PUSHER );
  _setType( WT_CART_PUSHER );

  _d->storageBuildingPos = TilePos( -1, -1 );
  _d->baseBuildingPos = TilePos( -1, -1 );
  _d->maxDistance = 25;
  _d->city = city;

  setName( NameGenerator::rand( NameGenerator::male ) );
}
开发者ID:brobits,项目名称:opencaesar3,代码行数:13,代码来源:cart_supplier.cpp

示例3: getTile

void Construction::_updateDesirabilityInfluence( bool onBuild )
{
  City &city = Scenario::instance().getCity();
  Tilemap &tilemap = city.getTilemap();

  PtrTilesList desirabilityArea = tilemap.getFilledRectangle( getTile().getIJ() - TilePos( 2, 2 ), 
    getTile().getIJ() + TilePos( 2 + getSize(), 2 + getSize() ) );

  int mul = (onBuild ? 1 : -1);
  for( PtrTilesList::iterator it=desirabilityArea.begin(); it != desirabilityArea.end(); it++ )
  {
    (*it)->get_terrain().appendDesirability( mul * getDesirabilityInfluence() );
  }
}
开发者ID:LMG,项目名称:opencaesar3,代码行数:14,代码来源:oc3_building.cpp

示例4: WarehouseTile

void Warehouse::init()
{
  _fgPictures[0] = &Picture::load(ResourceGroup::warehouse, 1);
  _fgPictures[1] = &Picture::load(ResourceGroup::warehouse, 18);
  _fgPictures[2] = _animation.getCurrentPicture();
  _fgPictures[3] = _animFlag.getCurrentPicture();

  // add subTiles in Z-order (from far to near)
  _subTiles.clear();
  _subTiles.push_back( WarehouseTile( TilePos( 1, 2 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 0, 1 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 2, 2 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 1, 1 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 0, 0 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 2, 1 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 1, 0 ) ));
  _subTiles.push_back( WarehouseTile( TilePos( 2, 0 ) ));

  for (unsigned int n = 0; n<_subTiles.size(); ++n)
  {
     _fgPictures[n+4] = &_subTiles[n]._picture;
  }

  _goodStore.init(*this);

  GoodStock stock;
  stock._goodType = G_POTTERY;
  stock._currentQty = 300;
  _goodStore.store(stock, 300);

  computePictures();
}
开发者ID:Rovanion,项目名称:opencaesar3,代码行数:32,代码来源:oc3_warehouse.cpp

示例5: Size

void BuildingPrefecture::deliverService()
{
  if( getWorkers() > 0 && getWalkerList().size() == 0 )
  {
    bool fireDetect = _fireDetect.getI() >= 0;
    WalkerPrefectPtr walker = WalkerPrefect::create( Scenario::instance().getCity() );
    walker->setMaxDistance( 26 );

    //bool patrol = true;
    if( fireDetect )
    {
      PathWay pathway;
      TilePos startPos = _accessRoads.front()->getIJ();
      bool pathFounded = Pathfinder::getInstance().getPath( startPos, _fireDetect, pathway, false, Size( 0 ) );
      //patrol = !pathFounded;

      if( pathFounded )
      {
        walker->setPathWay( pathway );
        walker->setIJ( pathway.getOrigin().getIJ() );
      }

      _fireDetect = TilePos( -1, -1 );
    }
    
    walker->send2City( BuildingPrefecturePtr( this ), fireDetect ? 200 : 0 );

    addWalker( walker.as<Walker>() );
  }
}
开发者ID:akuskis,项目名称:opencaesar3,代码行数:30,代码来源:oc3_building_prefecture.cpp

示例6: TilePos

void TileOverlay::build( CityPtr city, const TilePos& pos )
{
  Tilemap &tilemap = city->getTilemap();

  _d->city = city;
  _d->masterTile = &tilemap.at( pos );

  for (int dj = 0; dj < _d->size.getWidth(); ++dj)
  {
    for (int di = 0; di < _d->size.getHeight(); ++di)
    {
      Tile& tile = tilemap.at( pos + TilePos( di, dj ) );
      tile.setMasterTile( _d->masterTile );
      tile.setPicture( &_d->picture );

      if( tile.getOverlay().isValid() && tile.getOverlay() != this )
      {
        tile.getOverlay()->deleteLater();
      }

      tile.setOverlay( this );
      initTerrain( tile );
    }
  }
}
开发者ID:BlackFoks,项目名称:opencaesar3,代码行数:25,代码来源:tileoverlay.cpp

示例7: fread

void WDT::ReadTileTable()
{
    Chunk* chunk = Data->GetChunkByName("MAIN");
    if (!chunk)
        return;
    IsValid = true;
    FILE* stream = chunk->GetStream();
    for (int y = 0; y < 64; ++y)
    {
        for (int x = 0; x < 64; ++x)
        {
            const uint32 hasTileFlag = 0x1;
            uint32 flags;
            uint32 discard;
            int count = 0;
            count += fread(&flags, sizeof(uint32), 1, stream);
            count += fread(&discard, sizeof(uint32), 1, stream);

            if (count != 2)
                printf("WDT::ReadTileTable: Failed to read some data expected 2, read %d\n", count);

            if (flags & hasTileFlag)
                TileTable.push_back(TilePos(x, y));

        }
    }
}
开发者ID:Allowed,项目名称:SkyFire_5xx,代码行数:27,代码来源:WDT.cpp

示例8: 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

示例9: 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

示例10: TilePos

TilePosList TileGrid::nearestNeighbors(TilePos origin)
{
   TilePosList toReturn;
   toReturn.reserve(8);

   auto mods = { -1, 0, 1 };

   for (auto &x : mods)
   {
      for (auto &y : mods)
      {
         if (x || y)
         {
            auto pos = TilePos(origin.x + x, origin.y + y);

            if (isTilePosValid(pos))
            {
               toReturn.push_back(pos);
            }
         }
      }
   }

   return toReturn;
}
开发者ID:ghbenjamin,项目名称:NotPathfinder,代码行数:25,代码来源:TileGrid.cpp

示例11: _city

void Fishery::timeStep(const unsigned int time )
{  
  if( !game::Date::isMonthChanged() )
    return;

  if( _d->places.empty() )
  {
    _d->places = city::statistic::getWalkers<FishPlace>( _city(), walker::fishPlace, TilePos(-1, -1) );
  }

  while( _d->places.size() < _d->maxFishPlace )
  {
    FishPlacePtr fishplace = FishPlace::create( _city() );
    TilePos travelingPoint = _city()->borderInfo().boatExit;
    if( !_d->locations.empty() )
    {
      travelingPoint = _d->locations.size() > 1
                         ? _d->locations[ math::random( _d->locations.size() ) ]
                         : _d->locations.front();
    }

    fishplace->send2city( _city()->borderInfo().boatEntry, travelingPoint );

    if( fishplace->isDeleted() )
    {
      _d->nFailed++;
      return;
    }

    _d->places.push_back( ptr_cast<FishPlace>( fishplace ) );
  }

  utils::eraseDeletedElements( _d->places );
}
开发者ID:Ecordonnier,项目名称:caesaria-game,代码行数:34,代码来源:cityservice_fishplace.cpp

示例12: rect

std::list<Tile*> Tilemap::getRectangle( const TilePos& start, const TilePos& stop, const bool corners /*= true*/ )
{
    std::list<Tile*> res;

    int delta_corners = 0;
    if (! corners)
    {
        delta_corners = 1;
    }

    /*Rect maxRect( 0, 0, _size, _size );
    Rect rect( start.getI()+delta_corners, start.getJ()+delta_corners, 
               stop.getI()-delta_corners, stop.getJ()-delta_corners );

    rect.constrainTo( maxRect );
    for( int i=rect.getLeft(); i < rect.getRight(); i++ )
        for( int j=rect.getTop(); j < rect.getBottom(); j++ )
            ret.push_back( &at( TilePos( i, j ) ) );
    */
    for(int i = start.getI()+delta_corners; i <= stop.getI()-delta_corners; ++i)
    {
        if (is_inside( TilePos( i, start.getJ() ) ))
        {
            res.push_back( &at(i, start.getJ() ));
        }

        if (is_inside( TilePos( i, stop.getJ() ) ))
        {
            res.push_back( &at( i, stop.getJ() ));
        }
    }

    for (int j = start.getJ()+1; j <= stop.getJ()-1; ++j)  // corners have been handled already
    {
        if (is_inside( TilePos( start.getI(), j ) ))
        {
            res.push_back(&at(start.getI(), j));
        }

        if (is_inside( TilePos( stop.getI(), j ) ))
        {
            res.push_back(&at(stop.getI(), j));
        }
    }

    return res;
}
开发者ID:DarkLotus,项目名称:opencaesar3,代码行数:47,代码来源:oc3_tilemap.cpp

示例13: 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

示例14: ServiceBuilding

Prefecture::Prefecture() : ServiceBuilding(Service::prefect, constants::building::prefecture, Size(1))
{
  _fireDetect = TilePos( -1, -1 );
  setPicture( ResourceGroup::security, 1 );
  
  _getAnimation().load( ResourceGroup::security, 2, 10);
  _getAnimation().setDelay( 4 );
  _getAnimation().setOffset( Point( 20, 36 ) );
  _getFgPictures().resize(1);
}
开发者ID:BlackFoks,项目名称:opencaesar3,代码行数:10,代码来源:prefecture.cpp

示例15: ServiceBuilding

Prefecture::Prefecture() : ServiceBuilding(Service::S_PREFECT, B_PREFECTURE, Size(1))
{
  _fireDetect = TilePos( -1, -1 );
  setPicture( Picture::load( ResourceGroup::security, 1 ) );
  
  _getAnimation().load( ResourceGroup::security, 2, 10);
  _getAnimation().setFrameDelay( 4 );
  _getAnimation().setOffset( Point( 20, 36 ) );
  _fgPictures.resize(1);
}
开发者ID:hellium,项目名称:opencaesar3,代码行数:10,代码来源:oc3_building_prefecture.cpp


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