Пример #1
0
void Hpa::ignoreAroundActors(const fdkgame::findpath::GridMap& env, const Location& center, float radius)
{
	BoundingBox bb(center-Location(radius,radius), center+Location(radius,radius));
	for (ActorBank::Actors::const_iterator it = g_ActorBank.getActors().begin(); it != g_ActorBank.getActors().end(); ++it)
	{
		Actor* actor = *it;
		if (actor == m_actor)
		{
			continue;
		}
		if (!actor->getBoundingBox().intersect(bb))
		{
			continue;
		}
		const short mlvr = env.getMinClearanceValueRequired();
		CellCoord tl = util::locationToCellCoord(actor->getBoundingBox().topLeft);
		CellCoord br = util::locationToCellCoord(Location(actor->getBoundingBox().bottomRight.x-1, actor->getBoundingBox().bottomRight.y-1));
		tl.x -= (mlvr-1);
		tl.y -= (mlvr-1);
		for (int y = tl.y; y <= br.y; ++y)
		{
			for (int x = tl.x; x <= br.x; ++x)
			{
				m_ignoredNodes.insert(env.toNodeID(CellCoord(x, y)));
			}
		}
	}
}
Пример #2
0
bool HpaMap::reloadFromFile(const char* fileName)
{
	std::ifstream ifs(fileName);
	if (!ifs)
	{
		util::output("can't load hpa map from file '%s'", fileName);
		return false;
	}
	g_Board.clearBlocks();
	size_t width, height;
	ifs >> width >> height;
	for (size_t y = 0; y < height; ++y)
	{
		for (size_t x = 0; x < width; ++x)
		{
			int i;
			ifs >> i; 
			if (i)
			{
				g_Board.setBlock(CellCoord(x, y), true);
			}
		}
	}
	g_Board.annotateMap();
	rebuildAbstract();
	return true;
}
Пример #3
0
Файл: Util.cpp Проект: sjfyc/fdk
	CellCoord locationToCellCoord(const Location& location)
	{
		return CellCoord(
			static_cast<CellCoord::ValueType>(location.x/CELL_SIZE_X), 
			static_cast<CellCoord::ValueType>(location.y/CELL_SIZE_Y)
			);
	}
Пример #4
0
UniformGrid::CellCoord UniformGrid::coordAt(int index) const {
  int z = index % sideLength;
  index /= sideLength;
  int y = index % sideLength;
  index /= sideLength;
  int x = index;
  return CellCoord(x, y, z);
}
Пример #5
0
void Board::drawCenterVertex()
{
	for (short x = 0; x < CELL_COUNT_X; ++x)
	{
		for (short y = 0; y < CELL_COUNT_Y; ++y)
		{
			util::fillRectByCenter( util::cellCoordToLocationInCenter(CellCoord(x, y)), Location(2, 2), ARGB(255,122,143,177));
		}
	}
}
Пример #6
0
UniformGrid::CellCoord UniformGrid::coordAt(const Point3D& pt) const {
  // Adjust so that the minimum will be at (0, 0, 0)
  Point3D p(pt[0] - startPoint[0], pt[1] - startPoint[1], pt[2] - startPoint[2]);
  auto c = CellCoord(
    (int) (p[0] / cellSize),
    (int) (p[1] / cellSize),
    (int) (p[2] / cellSize)
  );
  for (int i = 0; i < 3; ++i) {
    if (c[i] >= sideLength) c[i] -= 1;
  }
  return c;
}
Пример #7
0
void TileMap::drawCellInfo()
{
	for (int y = 0; y < CELL_COUNT_Y; ++y)
	{	
		for (int x = 0; x < CELL_COUNT_X; ++x)
		{
			if (g_Option.isOn(Option::Toggle_ShowCellCoord))
			{
				g_Font.printf(x*CELL_SIZE_X+2, y*CELL_SIZE_Y+2, HGETEXT_LEFT, "%d,%d", x, y);
			}
			if (g_Option.isOn(Option::Toggle_ShowCellID))
			{
				g_Font.printf(x*CELL_SIZE_X+2, y*CELL_SIZE_Y+2, HGETEXT_LEFT, "%d", toCellID(CellCoord(x, y) ) );
			}
		}
	}
}
Пример #8
0
void TileMap::draw()
{
	const DWORD COLOR_BOARD_LINE = 0x55020202;
	for (int i = 0; i <= CELL_COUNT_Y; ++i) // ºáÏß
	{	
		g_HGE->Gfx_RenderLine(0, i*CELL_SIZE_Y, CELL_COUNT_X*CELL_SIZE_X, i*CELL_SIZE_Y, COLOR_BOARD_LINE);
	}
	for (int i = 0; i <= CELL_COUNT_X; ++i) // ÊúÏß
	{
		g_HGE->Gfx_RenderLine(i*CELL_SIZE_X, 0, i*CELL_SIZE_X, CELL_COUNT_Y*CELL_SIZE_Y, COLOR_BOARD_LINE);
	}
	for (short x = 0; x < CELL_COUNT_X; ++x)
	{
		for (short y = 0; y < CELL_COUNT_Y; ++y)
		{
			util::fillCell(CellCoord(x, y), getTileColor(getTileType(fdkgame::navi::CellCoord(x, y))) );
		}
	}
}
Пример #9
0
void Board::drawCellClearanceValue()
{
	for (int y = 0; y < CELL_COUNT_Y; ++y)
	{	
		for (int x = 0; x < CELL_COUNT_X; ++x)
		{
			g_Font.printf(x*CELL_SIZE_X+2, y*CELL_SIZE_Y+2, HGETEXT_LEFT, "%d", getClearanceValue(toNodeID(CellCoord(x, y)) ) );
		}
	}
}