Ejemplo n.º 1
0
bool MapManager::isLocationReachable(Actor& actor, const Location& location)
{
	const fdkgame::navi::VertexMap& vertexMap = getVertexMap(
		fdkgame::navi::VertexMapType( actor.getMoveCapability(), actor.getUnitSize() )
		);
	VertexCoord testVertexCoord = util::locationToNearestVertexCoord(location);
	if (!vertexMap.isBlock(testVertexCoord) )
	{
		return true;
	}

	//const Velocity& velocity = actor.getVelocity();
	//if ((velocity.x > 0 && velocity.y > 0) || // 右下
	//	(velocity.x < 0 && velocity.y < 0) ) // 左上
	//{
	//	if (!vertexMap.isBlock(testVertexCoord+VertexCoord(1, -1)) || // 右上角可走
	//		!vertexMap.isBlock(testVertexCoord+VertexCoord(-1, 1)) ) // 左下角可走
	//	{
	//		return true;
	//	}
	//}
	//else if ((velocity.x > 0 && velocity.y < 0) || // 右上
	//	(velocity.x < 0 && velocity.y > 0) ) // 左下
	//{
	//	if (!vertexMap.isBlock(testVertexCoord+VertexCoord(1, 1)) || // 右下角可走
	//		!vertexMap.isBlock(testVertexCoord+VertexCoord(-1, -1)) ) // 左上角可走
	//	{
	//		return true;
	//	}
	//}
	return false;
}
Ejemplo n.º 2
0
void MapManager::draw()
{
	const fdkgame::navi::VertexMap& vertexMap = getVertexMap(
		fdkgame::navi::VertexMapType(g_Option.getMoveCapability(), g_Option.getUnitSize())
		);

	if (g_Option.isOn(Option::Toggle_ShowVertex))
	{		
		for (int y = 0; y < vertexMap.getSizeY(); ++y)
		{
			for (int x = 0; x < vertexMap.getSizeX(); ++x)
			{
				util::drawVertex(VertexCoord(x, y), 
					(vertexMap.getBlockValue(VertexCoord(x, y)) > 0) ? ARGB(255, 226, 98, 29) : ARGB(255, 131, 164, 108)
					);
			}
		}
	}	

	if (g_Option.isOn(Option::Toggle_ShowVertexCoordInMouse))
	{
		Location mouseLocation;
		g_HGE->Input_GetMousePos(&mouseLocation.x, &mouseLocation.y);

		VertexCoord vertexCoord = util::locationToNearestVertexCoord(mouseLocation);

		g_Font.printf(mouseLocation.x-20.0f,mouseLocation.y-20.0f,HGETEXT_LEFT,"%d,%d", vertexCoord.x, vertexCoord.y);
	}	
	if (g_Option.isOn(Option::Toggle_ShowVertexIDInMouse))
	{
		Location mouseLocation;
		g_HGE->Input_GetMousePos(&mouseLocation.x, &mouseLocation.y);

		VertexCoord vertexCoord = util::locationToNearestVertexCoord(mouseLocation);

		if (vertexMap.isValidNodeCoord(vertexCoord))
		{
			g_Font.printf(mouseLocation.x-20.0f,mouseLocation.y-20.0f,HGETEXT_LEFT,"%d", vertexMap.toNodeID(vertexCoord) );
		}		
	}
}
Ejemplo n.º 3
0
void MeshBuilder::removeVertex( int index )
{
	assert( 0 == getVertex(index)->polygons() ); // no polygon can use the vertex

	Vertex* item = getVertex(index);
	item->destroy();
	m_this->vertices.remove( index );
	freeVertex( item );

	// update vertex indices
	int i;
	for ( i = index ; i < (int)m_this->vertices.size() ; ++i )
		m_this->vertices[i]->m_index = i;

	// update discontinuous vertex map indices
	for ( i = 0 ; i < discontinuousVertexMaps() ; ++i )
		getDiscontinuousVertexMap(i)->vertexRemoved( index );

	// update discontinuous vertex map indices
	for ( i = 0 ; i < vertexMaps() ; ++i )
		getVertexMap(i)->vertexRemoved( index );
}