#ifndef GAMEHEROESOFCIS
#define GAMEHEROESOFCIS

/*
	The heroesproto.h file is the header file for the prototype of the HeroesOfCIS arcade game.
	This file is heavily based off the gamestub.h file that is distributed with the POP
	framework and includes a lot of code and comments from that file.

	In the code below, we put the word virtual in front of all the methods that we have
	inherited from the base classes and which we plan to overload.  (These methods were
	already declared as virtual in the base classes, so that our overloads can take effect.
	Declaring them virtual in this child class only means that they could be further overloaded 
	in the children of the child.)
*/

#include "game.h"
#include "critterarmed.h"

	/* Printer ID constants */
	enum printerName {
		PRINTER_UNNAMED = 0,
		PRINTER_ODIE,
		PRINTER_CUJO,
		PRINTER_LASSIE,
		PRINTER_ASTRO,
		PRINTER_CLIFFORD,
		PRINTER_DINO,
	};

//=== cGameHeroesOfCIS Critters ====================================

class cCritterWrenchStatusIcon : public cCritter
{
DECLARE_SERIAL(cCritterWrenchStatusIcon);

private:
	static Real WRENCH_STATUS_ICON_RADIUS;

public:
	cCritterWrenchStatusIcon(cGame *pownergame = NULL);

	void setWrenchStatus(BOOL status);
};

class cCritterHeroesPlayer : public cCritterPlayer //Our player.
{
DECLARE_SERIAL(cCritterHeroesPlayer);

/* Constants for Player Class */
static Real MAX_SPEED;

private:
	int _wrench;
	cCritterWrenchStatusIcon* _pwrenchicon;

public:
	cCritterHeroesPlayer(cGame *pownergame = NULL);

	int wrench()const{return _wrench;}

//overloads
	virtual void reset();
	virtual int damage(int hitstrength);
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(CPopView *pactiveview, Real dt);
};

class cCritterPrintQueueTray : public cCritter
{
DECLARE_SERIAL(cCritterPrintQueueTray);

private:
	static Real PRINT_QUEUE_TRAY_RADIUS;
	static Real PRINT_QUEUE_TRAY_OFFSET;

public:
	cCritterPrintQueueTray(cGame *pownergame = NULL);

	void initializePrintQueueTray(printerName pID, cVector queueposition);
	void setTrayIcon(printerName pID);
};


class cCritterPrintQueue : public cCritter
{
DECLARE_SERIAL(cCritterPrintQueue);

private:

	/* Static parameters. */
	static Real PRINT_QUEUE_RADIUS;
	static int MAX_QUEUE;

	/* Other parameters. */
	cCritterPrintQueueTray* _pprintqueuetray; 
	int _queue;
	cRealBox _statusbox;


public:
	cCritterPrintQueue(cGame *pownergame = NULL);

	void initializePrintQueue(printerName pID);
	void positionPrintQueue(printerName pID);
	BOOL queueOverflow(){return (_queue > MAX_QUEUE)? TRUE : FALSE;}

//accessors
	int queue(){return _queue;}
	void setQueue(int value){_queue = value;}
	void incQueue(int value){_queue += value;}
	void decQueue(int value){_queue = max(0, _queue - value);}

//overloads
	virtual void update(CPopView *pactiveview, Real dt);
};

class cCritterSupplyCabinet : public cCritter
{
DECLARE_SERIAL(cCritterSupplyCabinet);
public:
	cCritterSupplyCabinet(cGame *pownergame = NULL);

//overloads
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(CPopView *pactiveview, Real dt);
};

class cCritterPrinter : public cCritter
{
DECLARE_SERIAL(cCritterPrinter);

private:

	static Real PRINTER_RADIUS;

	printerName _printerID; // Printer ID for choosing graphics sprites, print queue location, etc.
	cCritterPrintQueue* _pprintqueue; // Pointer to printer's print queue
	BOOL _broken;
	BOOL _exploded;

public:

	cCritterPrinter(cGame *pownergame = NULL);

	int printerID(){return _printerID;}
	BOOL isBroken(){return _broken;}
	BOOL isExploded(){return _exploded;}

	void assignPrinterID(printerName pID);

	void breakMe();
	void fixMe();
	void explodeMe();
	void setBrokenSprite();
	void setFixedSprite();

//accessors
	cCritterPrintQueue* pprintqueue(){return _pprintqueue;}

//overloads
	virtual BOOL collide(cCritter *pcritter); 
	virtual void update(CPopView *pactiveview, Real dt);
};

//======================= cGameHeroesOfCIS ================


class cGameHeroesOfCIS : public cGame
{
DECLARE_SERIAL(cGameHeroesOfCIS);

/* Game world parameters */

	static Real BLANK_EDGE_WEIGHT; 
	static Real PLAYFIELD_WEIGHT;
	static Real PLAYFIELD_STATUSBOX_SPACER_WEIGHT; 
	static Real BOX_LINEWIDTH_WEIGHT; 
	static COLORREF PLAYFIELD_FILLCOLOR;
	static COLORREF PLAYFIELD_LINECOLOR;
	static COLORREF STATUSBOX_FILLCOLOR;
	static COLORREF STATUSBOX_LINECOLOR;

protected:
	int _level;

	int _rivalcount; //possible param, don't have to use it.
	int _printercount;

	cRealBox _playfield;
	cRealBox _statusbox;

	cCritterPrinter* _pprinter[6];
	cCritterSupplyCabinet* _psupplycabinet[4];

	BOOL printerExploded();

public:
	cGameHeroesOfCIS();

 /* Accessors */
	cRealBox playfield(){return _playfield;}
	cRealBox statusbox(){return _statusbox;}

 /* Player stats */
	int wrench();

 /* Other functions */

	void loadLevel(int level);

 /* Overloads */
	virtual void Serialize(CArchive& ar); //Overload for _rivalcount
	virtual void reset();
	virtual void adjustGameParameters();
	virtual CString statusMessage();
	virtual void initializeView(CPopView *pview);
	virtual void initializeViewpoint(cCritterViewer *pviewer); //To change the default view direction.
	virtual void drawBackground(cGraphics *pgraphics, int drawflags);
	virtual void drawForeground(cGraphics *pgraphics, int drawflags);
	virtual void seedCritters();
};

#endif //GAMEHEROESOFCIS