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


C++ Stairs::getDirection方法代码示例

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


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

示例1: scanForEntrances

  void Maze::scanForEntrances() {
    for (uint32_t i = 1; i <= getFloorCount(); i++) {
      Map* curMap = getFloor(i);
      
      if (i == 1) {
        //  In this case, we want up stairs.
        bool foundEntrance = false;
        bool multipleWarned = false;
        for (int32_t y = 0; y < curMap->getHeight(); y++) {
          for (int32_t x = 0; x < curMap->getWidth(); x++) {
            Activatable* act = curMap->getActivatable(x, y);
            if (act) {
              Stairs* stairs = act->asStairs();
              if (stairs && stairs->getDirection() == StairDirection::UP) {
                Facing dstFacing = stairs->getDestinationFacing();
                
                //  Adjust the position so that when the player enters, they're
                //  facing the right direction, and in the right position.
                int32_t dstX = x;
                int32_t dstY = y;
                switch(dstFacing) {
                case Facing::NORTH:
                  dstY--;
                  break;
                case Facing::EAST:
                  dstX++;
                  break;
                case Facing::SOUTH:
                  dstY++;
                  break;
                case Facing::WEST:
                  dstX--;
                  break;
                }

                if (foundEntrance && !multipleWarned) {
                  writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Multiple up stairs found on floor of maze.");
                  multipleWarned = true;
                }
                else {
                  if (!curMap->canEntityEnter(dstX, dstY)) {
                    writeToLog(MessageLevel::WARNING, "Maze::scanForEntrances():  Entrance as specified would place player in solid wall.");
                  }
                  else {
                    mazeEntrance = Entrance(i, dstX, dstY, dstFacing);
                    foundEntrance = true;
                  }
                }
              }
            }
          }
        }
      }
      else {
        //  Otherwise, we're looking for geomagnetic poles.  This is currently
        //  not implemented.  Mostly because geopoles don't exist.
      }
    }
  }
开发者ID:CepheidVar,项目名称:ProjectIO,代码行数:59,代码来源:Maze.cpp


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