#pragma once
//-----------------------------------------------------
// Name, first name: Hoet, Guntran
// Group: 1DAE3
//-----------------------------------------------------

//-----------------------------------------------------
// Include Files
//-----------------------------------------------------
#include "GameEngine.h"
//#include "Entity.h"
#include "Mario.h"
#include "Sound.h"


//-----------------------------------------------------
// Block Class									
//-----------------------------------------------------
class Block
{
public:
	Block(int x, int y, Bitmap * bitmapPtr, int blockType = 0, int condition = 1, int item = 0, int mushroomType = 0);				// Constructor
	virtual ~Block();		// Destructor

	//-------------------------------------------------
	// Methods - Member functions							
	//-------------------------------------------------

	virtual void Tick(double deltaTime);
	virtual void Paint(MATRIX3X2 matView);
	virtual void PaintHitregions(MATRIX3X2 matView);

	void BounceUp();
	void TakeDamageToCondition();
	void CheckBlockIfDestroyed();
	//0 = brick
	//1 = special
	//2 = steel
	//3 = invisible
	//4 = hidden brick
	int GetBlockType();
	bool IsIndestructable();
	RECT2 GetAABBRect();
	DOUBLE2 GetPos();
	//0=nothing
	//1=coin
	//2=flower
	//3=mushroom
	//4=star
	int GetItemType();
	//0 = normal (standard)
	//1 = 1 UP
	int GetMushroomType();

private: 
	enum class BlockType : int
	{
		BRICK_NORMAL,	// #0	(default type)
		SPECIAL,		// #1
		STEEL,			// #2
		INVISIBLE,		// #3
		HIDDEN_BRICK		// #4
	};

	enum class Item : int
	{
		NOTHING,
		COIN,
		FLOWER,
		MUSHROOM,
		STAR
	};


	// -------------------------
	// Member functions
	// -------------------------

	void DetermineClipRect();
	void BlockGravity(double deltaTime);

	//-------------------------------------------------
	// Datamembers								
	//-------------------------------------------------
	static const int INTERVAL = 10;
	static const int FORCE_BOUNCE = 800;
	static const int FORCE_GRAVITY = 10;

	bool m_IsDestroyed, m_IsIndestructable;

	int m_BlockSize, m_BlockTypeNumber, m_Condition, m_MarioFormState, 
		m_TickCount, m_BlockAnimation, m_LowestYPos;

	int m_Item, m_MushroomType;

	double m_DeltaTime;

	Bitmap* m_BmpBlockPtr;

	DOUBLE2 m_Position;

	RECT m_ClipRect;

	BlockType m_BlockType;

	// -------------------------
	// Disabling default copy constructor and default 
	// assignment operator.
	// -------------------------
	Block(const Block& yRef);									
	Block& operator=(const Block& yRef);	
};


