#include "LauncherBlock.hpp"
#include "Game.hpp"
#include "Ball.hpp"
#include "Extra.hpp"

LauncherBlock::LauncherBlock(Game* g, Entity* LaunchedEntity):
Block(g, true),
m_LaunchedEntity(LaunchedEntity)
{
}


void LauncherBlock::onHit()
{
	//destroy the block
	manager->markToRemove(this);

	if(dynamic_cast<Extra*>(m_LaunchedEntity))
	{
		game->PlaySound("block_launch_extra");
	}
	else if(dynamic_cast<Ball*>(m_LaunchedEntity))
	{
		game->PlaySound("block_launch_ball");
	}
	m_LaunchedEntity->setPosition(position+(cm.max-cm.min)/2);//place the new entity in the middle of this block

	manager->addEntity(m_LaunchedEntity);

}
