Exemplo n.º 1
0
float ClosetoBorderFactor::calcDecision(Crood &crood)
{
	int close = 5;
	MapDataManager* mapdata = MapDataManager::getSingletonPtr();
	int mapsize = mapdata->getMapSize();
	for(int x = crood.mX - 2; x <= crood.mX + 2; x++)
	{
		for(int y = crood.mY- 2; y <= crood.mY + 2; y++)
		{
			bool out = false;
			if(x < -1 || y < -1 || x > mapsize || y > mapsize)
			{
				out = true;
			}
			else
			{
				int id = mapdata->getGridId(x, y);
				std::set<int>::iterator ite = mAreaSet.find(id);
				if(mAreaSet.end() == ite)
				{
					out = true;
				}
			}
			if(out)
			{
				int dist = GetDistance(x, y, crood.mX, crood.mY);
				if(dist < close )
					close = dist;
			}
		}
	}
	return 100.0f - 25.0f * close;
}
Exemplo n.º 2
0
//ClosetoBorderFactor
ClosetoBorderFactor::ClosetoBorderFactor(Area &area)
{
	MapDataManager* mapdata = MapDataManager::getSingletonPtr();
	int mapsize = mapdata->getMapSize();
	std::vector<Crood> croodvec = area.getCroodVec();
	std::vector<Crood>::iterator ite = croodvec.begin();
	for( ; ite != croodvec.end(); ite++ )
	{
		if((*ite).mX < -1 || (*ite).mY < -1 || (*ite).mX > mapsize || (*ite).mY > mapsize)
		{
			continue;
		}
		mAreaSet.insert(mapdata->getGridId((*ite).mX, (*ite).mY));
	}
}