#ifndef H_CGAME
#define H_CGAME
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <vector>
using namespace std;
#include "MediaVars.h"
#include "cObject.h"
#include "cPlayer.h"
#include <ctime>

enum STATENUM { ST_HEART, ST_DOOR, ST_DIED, ST_SIGN };
enum GAMESTATE { CS_TITLE, CS_LOSE, CS_LEVEL, CS_WIN, CS_WINSTORY, CS_STORY1, CS_STORY2, CS_STORY3 };

class cGame
{
private:
	vector<cObject*> vctrObjects;
	vector<cObject*> vctrDrawObjects;
	vector<std::string> vctrLevels;
	vector<vector<sf::Vector2i*>*> vctrItemsObtained;
	sf::RenderWindow *window;
	sf::View view;
	double levelWidth;
	double levelHeight;
	cPlayer* playerPtr;
	int playerHeart;
	int playerMaxHeart;
	bool hasBrain;
	bool transitioningRooms;
	unsigned int currentLevel;
	sf::Sprite *floorSprite;
	bool spaceDownPrevious, spaceDown;
	bool sKeyPrevious, sKeyDown;
	GAMESTATE currentState;
	unsigned int statHeartsObtained, statTimesDied, statDoorsOpened, statSignsRead;
	unsigned int totalNumberHearts, totalNumberSigns;
	bool gameRestarted;
	unsigned int tempNumberDead, tempNumberHearts, tempNumberDoors, tempNumberSigns;
	clock_t timeGameBegin, timeGameEnd;
public:
	cGame(sf::RenderWindow *win);
	void Start();
	void Do();
	void End();
	vector<cObject*> *GetObjectVector();
	sf::RenderWindow *GetWindow();
	cObject* AddObject(cObject* object);
	cObject* GetPlayer();
	void SortVector();
	sf::View *GetView();
	double GetLevelWidth();
	double GetLevelHeight();
	void ChangePlayerHeart(int amount);
	bool PlayerHasBrain();
	void ObtainedBrain();
	unsigned int GetCurrentLevel();
	void GenerateLevel(unsigned int level);
	void GoToNextLevel();
	void RestartLevel();
	unsigned int GetPlayerHeart();
	bool IsKeyPressed(sf::Key::Code key);
	bool IsKeyReleased(sf::Key::Code key);
	void PerformLevel();
	void SetState(GAMESTATE state);
	void AddItemToObtainedVector(double x, double y);
	void StatIncrease(STATENUM st);
	bool IsGameRestarted();
	void RestartGame();
	void CalculateStatVars();
	void PlaySound(sf::Sound *snd);
};
#endif