//---------------------------
// Includes
//---------------------------
#include "StdAfx.h"
#include "Food.h"

#include "Painter.h"
#include "ResourceLoader.h"
#include "InputState.h"
#include "CollisionMesh.h"
#include "Image.h"
//---------------------------
// Defines
//---------------------------
//

//---------------------------
// Constructor & Destructor
//---------------------------
Food::Food(ResourceLoader* resourceLoaderPtr, const String& imagename, double healthModifier)
:Item(resourceLoaderPtr,imagename)
{
	m_HealthModifier = healthModifier;
	m_CollisionMeshPtr = resourceLoaderPtr->GetCollisionMesh();
	m_CollisionMeshPtr->CreateRect(0, 0, m_ImagePtr->GetWidth(), m_ImagePtr->GetHeight());
}

Food::~Food()
{
	SafeDelete(&m_ImagePtr);
	delete m_CollisionMeshPtr;
}

bool Food::HitTest(Character *characterPtr)
{
	CollisionMesh *characterVMesh=characterPtr->GetVCollisionMesh();
	CollisionMesh *characterHMesh=characterPtr->GetHCollisionMesh();

	if(characterVMesh->HitTest(m_CollisionMeshPtr) || characterHMesh->HitTest(m_CollisionMeshPtr))
	{
		characterPtr->ChangeCurrentHitPoints((int)(characterPtr->GetHitPoints()*m_HealthModifier));
		return true;
	}
	return false;
}