/*
Header file for CIsland class
 */

#ifndef _ISLANDWORLD_H_
#define _ISLANDWORLD_H_

#define SKY_LIST 1
#define LAND_LIST 2
#define WATER_LIST 3
#define CLIFFS_LIST 4
#define ROCKS_LIST 5
#define MAX_CHILDREN 5

#define TERRAIN_SIZE 20
#define TERRAIN_EDGE (TERRAIN_SIZE / 2)
#define TERRAIN_SCALE (500.0 / TERRAIN_EDGE)

#define WATER_SIZE 20
#define WATER_EDGE (WATER_SIZE / 2)
#define WATER_SCALE	 (500.0 / WATER_EDGE)

#define WORLD_SIZE (WATER_SIZE + TERRAIN_SIZE)
#define WORLD_EDGE (TERRAIN_EDGE + WATER_EDGE) 
#define WORLD_SCALE (500.0 / WORLD_EDGE)

#define GRASS_HEIGHT		0.0
#define WATER_HEIGHT		0.0

#define FOGGY		0
#define SUNNY		1
#define TEXTURED 2
#define COLORED 3

#include "rock.h"
#include "Helpers/texture.h"
#include "IslandPerson.h"
#include "face.h"
#include "BoundingBox/BoundingBoxTree.h"

class CIslandWorld : public CObject
{
	public:
	int GetCurrentCharacter();
	void ChangeCharacter(int code);
	
	void ToggleCurrentDisplayMethod(void);
	int GetDisplayMethod(void);
	void SetWeather(int nWeather);
	int GetWeather();
	
	void KeyPressedInDirection(int nChar);
	void KeyUpInDirection(int nChar);
		CIslandWorld();
		virtual ~CIslandWorld();
		void CreateIsland(void);
		void DrawIslandScene(void);
		// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CIslandDoc)
	public:
	virtual void Serialize(CArchive& ar);
	//}}AFX_VIRTUAL
	protected:
	BOOL m_bDead;
		CList<CIslandPerson*, CIslandPerson*> m_children;
	void CreateBoundingBoxTree(void);
	void SetupCliffs(double dTerrainHeights[TERRAIN_SIZE][TERRAIN_SIZE]);
	void SetupRocks(double dTerrainHeights[TERRAIN_SIZE][TERRAIN_SIZE]);
	int m_nCurrentWeather;
	int m_nDisplayMethod;
	void DrawCliffSide(double dRockCoords[TERRAIN_SIZE][2][3],  double dHeight, int numCells);
	void CreateWater();
	void CreateLand(void);
	void CreateSky(void);
	void DrawRocks(void);
	CTexture m_skyTexture;
	CTexture m_landTexture;
	CTexture m_waterTexture;
	CTexture m_rockTexture;
	float m_skyColor[4];
	float m_landColor[4];
	float m_waterColor[4];
	float m_rockColor[4];
	CIslandPerson* m_currentPerson;
	CIslandPerson* m_guyPerson;
	CIslandPerson* m_girlPerson;
	CIslandPerson* m_godPerson;
	CList <CRock *, CRock *> m_rocks;
	CList <CRock *, CRock *> m_rocksGlobal;
	//will contain a list of faces we care about colliding with
	CList <CFace *, CFace *> m_cliffsBackGlobal;
	CList <CFace *, CFace *> m_cliffsFrontGlobal;
	CList <CFace *, CFace *> m_cliffsLeftGlobal;
	CList <CFace *, CFace *> m_cliffsRightGlobal;
	CList <CFace *, CFace *> m_groundGlobal;
	CBoundingBoxTree* m_islandObjectsBoundingBoxTree;
	CBoundingBoxTree* m_islandGroundBoundingBoxTree;
	CFace* ComputeGlobalRockFaceFor(CFace * backFace);
	CFace* ComputeGlobalCliffFaceFor(CFace * backFace);
	CFace* ComputeGlobalLandFaceFor(CFace * backFace);
	
};

#endif // _ISLANDWORLD_H_
