Example #1
0
void CGame2View::ProcessSelected()
{

	CGame2Doc			*pDoc = GetDocument();

	ASSERT_VALID(pDoc);

	GameMapObserver	*GameMap = pDoc->GetMap();
	Unit					*theUnit;

	int max_x = pDoc->GetMapWidth();
	int max_y = pDoc->GetMapHeight();
	int x,y;

	// TODO
	// optimize so that we only look in the map near where 
	// our bounding box is located.
	for(x = 0; x < max_x; x++)
	{
		for(y = 0; y < max_y; y++)
		{
			// if something is at this map location...
			if( theUnit = GameMap->RequestLoc(x,y) )
			{
				if(mPointSelectMode)
				{
					if(	theUnit->GetUnitRect().PtInRect(mCurSelectPoint))
					{
						theUnit->Select();
					}
					else
					{
						theUnit->UnSelect();
					}
				}
				else
				{
					if(	mCurSelectRect.PtInRect(theUnit->GetUnitPoint()))
					{
						theUnit->Select();
					}
					else
					{
						theUnit->UnSelect();
					}
				}
			}
		}
	}
}