Beispiel #1
0
City* Game::CreateCity( const Point& pos, Faction& owner )
{
	// Create a graphical entity
	ITexture* pTexture = AssetManager::Get().GetAsset< ITexture >( "BTNSteelMelee.png" );

	Material* pMaterial = AssetManager::Get().GetAsset<Material>( "Materials/GhoulMat.xmat" );

	// Create entity
	Entity* pCubeEntity = GameManager::CreateEntity();

	MeshComponent* pMesh = pCubeEntity->AddComponent<MeshComponent>();
	pMesh->SetMesh( Mesh::CreateBox() );
	pMesh->GetMesh()->Release();
	pMesh->SetMaterial( pMaterial );

	pCubeEntity->GetTransform().SetPosition( m_pWorld->GetPositionForTile( pos.x, pos.y ) );

	// Create the city
	City* pCity = pCubeEntity->AddComponent<City>();
	pCity->SetFaction( &owner );
	m_Cities.push_back( pCity );
	pCity->AddRef();

	m_pWorld->SetEntityPosition( pCubeEntity, pos.x, pos.y );

	return pCity;
}