//-----------------------------------------------------------------
// Game File
// C++ Source - SuperMarioBros.h - version v2_13 jan 2014 
// Copyright Kevin Hoefman - kevin.hoefman@howest.be
// http://www.digitalartsandentertainment.be/
//-----------------------------------------------------------------

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

#pragma once

//-----------------------------------------------------------------
// Include Files
//-----------------------------------------------------------------

#include "Resource.h"	
#include "GameEngine.h"
#include "AbstractGame.h"

#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;

#include "Level.h"
#include "HUD.h"
#include "Handy.h"
#include "Sound.h"
#include "Mario.h"

#include "EnemyList.h"
#include "BlockList.h"
#include "EntityList.h"

#include "CollisionList.h"

//-----------------------------------------------------------------
// SuperMarioBros Class																
//-----------------------------------------------------------------
class SuperMarioBros : public AbstractGame, public Callable
{
private:				
	//---------------------------
	// Constructor(s)
	//---------------------------
	SuperMarioBros();
	static SuperMarioBros* m_SuperMarioBrosPtr;

public:
	//---------------------------
	// Destructor
	//---------------------------
	virtual ~SuperMarioBros();
	static SuperMarioBros* GetSingleton();

	//---------------------------
	// General Methods
	//---------------------------

	void GameInitialize(HINSTANCE hInstance);
	void GameStart();				
	void GameEnd();
	//void MouseButtonAction(bool isLeft, bool isDown, int x, int y, WPARAM wParam);
	//void MouseMove(int x, int y, WPARAM wParam);
	//void CheckKeyboard();
	void KeyPressed(TCHAR cKey);
	void GameTick(double deltaTime);
	void GamePaint(RECT rect);
	void CallAction(Caller* callerPtr);
	DOUBLE2 GetCamPos();
	void SetCamPos(double x, double y);

	// statics
	static const int FORCE_GRAVITY = 1;
	static const int WORLD_SCALE = 4;
	static const int PLAY_TIME = 400;

	static const int SECRET_ROOM_Y = 224;

private:
	// -------------------------
	// Member functions
	// -------------------------

	void PaintHitregions(MATRIX3X2 matView);

	//void MarioToBlocksCollisionHandle();

	bool RectIntersectTest(RECT2 r1, RECT2 r2);
	RECT2 RectIntersect(RECT2 r1, RECT2 r2);

	void CameraTick(double deltaTime);
	void FreeCameraTick(double deltaTime);
	void OutputDebugConsole();

	// -------------------------
	// Datamembers
	// -------------------------

	bool m_PaintHitregions, m_FreeCamera, m_ShowQuitMessage, m_IsPaused, m_InvincibleMode;

	int m_WorldScale, m_TickCount, m_PlayTimeLeft;

	double m_CameraSpeed, m_CameraRotation, m_CameraScale;
	double m_DeltaTime, m_DeltaTimeMax;

	DOUBLE2 m_CameraPosition;

	Bitmap* m_BmpWorldPtr;
	//Bitmap* m_BmpMarioPtr;

	HitRegion* m_HitWorldPtr;

	Audio *m_AudOverworldPtr, *m_AudOverworldHurryPtr;

	Font* m_BitFontPtr;

	// mario
	//Mario* m_MarioPtr;

	// all enemies

	// all the interactive blocks
	BlockList *m_BlockListPtr;

	// collision
	//CollisionList *m_CollisionListPtr;

	// -------------------------
	// Disabling default copy constructor and default assignment operator.
	// If you get a linker error from one of these functions, your class is internally trying to use them. This is
	// an error in your class, these declarations are deliberately made without implementation because they should never be used.
	// -------------------------
	SuperMarioBros(const SuperMarioBros& tRef);
	SuperMarioBros& operator=(const SuperMarioBros& tRef);
};
