コード例 #1
0
ファイル: PathGenerator.cpp プロジェクト: Adiss/wowserver
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest, bool straightLine)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    G3D::Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);

    G3D::Vector3 start(x, y, z);
    SetStartPosition(start);

    _forceDestination = forceDest;
    _straightLine = straightLine;

    TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());

    // make sure navMesh works - we can run on map w/o mmap
    // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
    if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
        !HaveTile(start) || !HaveTile(dest))
    {
        BuildShortcut();
        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
        return true;
    }

    UpdateFilter();

    BuildPolyPath(start, dest);
    return true;
}
コード例 #2
0
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    Vector3 oldDest = GetEndPosition();
    Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);

    Vector3 start(x, y, z);
    SetStartPosition(start);

    _forceDestination = forceDest;

    sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath() for %u \n", _sourceUnit->GetGUIDLow());

    // make sure navMesh works - we can run on map w/o mmap
    // check if the start and end point have a .mmtile loaded (can we pass via not loaded tile on the way?)
    if (!_navMesh || !_navMeshQuery || _sourceUnit->HasUnitState(UNIT_STATE_IGNORE_PATHFINDING) ||
        !HaveTile(start) || !HaveTile(dest))
    {
        BuildShortcut();
        _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
        return true;
    }

    UpdateFilter();

    // check if destination moved - if not we can optimize something here
    // we are following old, precalculated path?
    float dist = _sourceUnit->GetObjectSize();
    if (oldDest != Vector3::zero() && InRange(oldDest, dest, dist, dist) && _pathPoints.size() > 2)
    {
        // our target is not moving - we just coming closer
        // we are moving on precalculated path - enjoy the ride
        sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::CalculatePath:: precalculated path\n");

        _pathPoints.erase(_pathPoints.begin());
        return false;
    }
    else
    {
        // target moved, so we need to update the poly path
        BuildPolyPath(start, dest);
        return true;
    }
}
コード例 #3
0
ファイル: PathGenerator.cpp プロジェクト: Exodius/chuspi
bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool /*forceDest*/)
{
    float x, y, z;
    _sourceUnit->GetPosition(x, y, z);

    if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z))
        return false;

    G3D::Vector3 dest(destX, destY, destZ);
    SetEndPosition(dest);
    SetActualEndPosition(GetEndPosition());

    G3D::Vector3 start(x, y, z);
    SetStartPosition(start);

    TC_LOG_DEBUG("maps", "++ PathGenerator::CalculatePath() for %u\n", _sourceUnit->GetGUIDLow());

    BuildShortcut();
    _type = PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH);
    return true;
}
コード例 #4
0
void DungeonGenerator::GenerateDungeon(Display &MainDisplay)
{
	currentRegion = -1;

	m_GroundImage = al_load_bitmap("GroundTile.jpg");

	m_Dungeon.resize(cm_DungeonWidth, std::vector<TILE>(cm_DungeonHeight, Wall));
	m_Regions.resize(cm_DungeonWidth, std::vector<int>(cm_DungeonHeight, currentRegion));
	
	AddRooms();

	for (int x = 1; x < cm_DungeonWidth; x += 2)
	{
		for (int y = 1; y < cm_DungeonHeight; y += 2)
		{
			if (Get_Tile(Vec2i(x, y)) != Wall)
			{
				continue;
			}
			
			GrowMaze(Vec2i(x,y));
		}
	}

	connectRegions();

	RemoveDeadEnds();

	//PrintCurrentMap();

	SetStartPosition();

	InitMap(MainDisplay);
	
	//MultiplyDungeon(2);
}
コード例 #5
0
ファイル: Character.cpp プロジェクト: Vincentkerstholt/KBSa
void Character::SetStartPosition(POINT point){
	SetStartPosition(point.x, point.y);
}
コード例 #6
0
ファイル: fen.cpp プロジェクト: raimarHD/lcec
  // ==================== //
  // コンストラクタと代入 //
  // ==================== //
  // コンストラクタ。
  FEN::FEN(const std::string fen_str) :
  to_move_(WHITE),
  castling_rights_(ALL_CASTLING),
  en_passant_square_(0),
  clock_(0),
  ply_(0) {
    // 駒の配置を初期化。
    INIT_ARRAY(position_);

    try {
      // 構文木にパース。
      std::map<std::string, std::string> tree = Util::ParseFEN(fen_str);

      // 配置を解析。
      std::string::iterator itr = tree["fen position"].begin();
      FOR_SQUARES(square) {
        Bitboard bb = Util::SQUARE[square][R0];

        switch (*itr) {
          case 'P':
            position_[WHITE][PAWN] |= bb;
            break;
          case 'N':
            position_[WHITE][KNIGHT] |= bb;
            break;
          case 'B':
            position_[WHITE][BISHOP] |= bb;
            break;
          case 'R':
            position_[WHITE][ROOK] |= bb;
            break;
          case 'Q':
            position_[WHITE][QUEEN] |= bb;
            break;
          case 'K':
            position_[WHITE][KING] |= bb;
            break;
          case 'p':
            position_[BLACK][PAWN] |= bb;
            break;
          case 'n':
            position_[BLACK][KNIGHT] |= bb;
            break;
          case 'b':
            position_[BLACK][BISHOP] |= bb;
            break;
          case 'r':
            position_[BLACK][ROOK] |= bb;
            break;
          case 'q':
            position_[BLACK][QUEEN] |= bb;
            break;
          case 'k':
            position_[BLACK][KING] |= bb;
            break;
        }

        ++itr;
      }

      // 手番を解析。
      if (tree["fen to_move"] == "w") {
        to_move_ = WHITE;
      } else {
        to_move_ = BLACK;
      }

      // キャスリングの権利を解析。
      castling_rights_ = 0;
      if (tree["fen castling"][0] != '-') {
        castling_rights_ |= WHITE_SHORT_CASTLING;
      }
      if (tree["fen castling"][1] != '-') {
        castling_rights_ |= WHITE_LONG_CASTLING;
      }
      if (tree["fen castling"][2] != '-') {
        castling_rights_ |= BLACK_SHORT_CASTLING;
      }
      if (tree["fen castling"][3] != '-') {
        castling_rights_ |= BLACK_LONG_CASTLING;
      }

      // アンパッサンのマスを解析。
      std::string temp = tree["fen en_passant"];
      if (temp != "-") {
        en_passant_square_ =
        Util::CoordToSquare(temp[0] - 'a', temp[1] - '1');
      }

      // 50手ルールの手数を解析。 あれば。
      if (tree.find("fen clock") != tree.end()) {
        clock_ = std::stoul(tree["fen clock"]);
      }

      // 手数を解析。 あれば。
      if (tree.find("fen ply") != tree.end()) {
        ply_ = std::stoul(tree["fen ply"]);
      }
    } catch (...) {
      SetStartPosition();
    }
  }
コード例 #7
0
ファイル: fen.cpp プロジェクト: raimarHD/lcec
 // デフォルトコンストラクタ。
 FEN::FEN() {
   SetStartPosition();
 }