
#ifndef __SEESAW_H__
#define __SEESAW_H__


#include "powerbar.h"
#include "loadsnd.h"

#define SEESAW_NUM_DRONES  4


#define SEESAW_BAR_LEFT    -232
#define SEESAW_BAR_TOP     100
#define SEESAW_BAR_HEIGHT  10
#define SEESAW_BAR_WIDTH   140
#define SEESAW_BAR_SLANT   0



enum
{
	SEESAW_STATE_RUNNING,
	SEESAW_STATE_FADEIN,
	SEESAW_STATE_INTRO,
	SEESAW_STATE_BRONZE_SUCCESS,
	SEESAW_STATE_SILVER_SUCCESS,
	SEESAW_STATE_GOLD_SUCCESS,

	SEESAW_STATE_FAIL,
	SEESAW_STATE_FINISH,
	SEESAW_STATE_FADEOUT,
};




typedef struct
{
	PSIMODEL *model;
	ACTOR *actor;
	VECTOR pos;
	VECTOR chickenPos;

	int yRot;
	int yTargetRot;
	long power;

	int animPos;

	int droneOnDevice;
	int nextDrone;

	PSIMODEL *winderModel;
	ACTOR	 *winderActor;

}deviceStr;




typedef struct
{
	int state;
	//int count;
	int incomingChicken; 

	PSIMODEL *model;
	ACTOR *actor;

	VECTOR pos;
	VECTOR targetPos;
	VECTOR vel;
	VECTOR acc;
	VECTOR oldPos;

}mattressStr;
	
enum
{
	MATTRESS_MOVING,
	MATTRESS_ARRIVED,
	MATTRESS_CATCHING,
	MATTRESS_MISSING,
	MATTRESS_LEAVING,
	MATTRESS_STOPPED,
};

typedef struct
{
	int state;

	VECTOR vel;
	int	rotAim;

	int xRotState;
	int xRotSpeed;

	VECTOR target;

	PSIMODEL *model;
	ACTOR *actor;

	int sound;
	SfxSampleType *weeSample;
}seesawDroneStr;

enum
{
	SEESAW_DRONE_INACTIVE,
	SEESAW_DRONE_WAITING,
	SEESAW_DRONE_RUNNINGON,
	SEESAW_DRONE_JUMPINGON,
	SEESAW_DRONE_ONDEVICE,
	SEESAW_DRONE_LAUNCHING,
	SEESAW_DRONE_FLYING,
	SEESAW_DRONE_CRASHING,
	SEESAW_DRONE_BOUNCING,
	SEESAW_DRONE_LANDING,
	SEESAW_DRONE_RUNNINGOFF,
	SEESAW_DRONE_RUNNINGFREEDOM,
	SEESAW_DRONE_LOOKAT,
};



typedef struct
{
	short active;
	short minutes;
	short tensseconds;
	short seconds;
	short tenths;
	short hundredths;

	long initialStartCount;
	long startCount;
}countDownTimerStr;


typedef struct 
{
	//camera debug
	VECTOR camPos;
	int camRotSpeed;
	int camDistToLookAt;

	long frameCount;
	int numChickensSaved;
	int state;
	int camRot;
	int playLaunchSample;

	countDownTimerStr  timer;

	SfxSampleType *pSamples[NUM_SEESAW_SAMPLES];


	deviceStr		device;
	mattressStr		mattress;
	seesawDroneStr	drones[SEESAW_NUM_DRONES];

	TextureType *shadow;

}seesawStr;




void seesawStart();
void seesawReset();
void seesawExit();


//void seesaw_SetupCamera(void);

void seesawDraw(void);
void seesawEnd(void);
void seesaw_UpdateCamAim(void);
void seesawCycle(void);

void seesawControls();

//void RotateCameraAroundLookAtPoint(int delta);
//void ssMoveCameraTowardsLookAtPoint(int delta);


void seesawPrintDebugText(void);
void mattressCatchChicken(int chicken, int framesToHit);
void mattressUpdate();
void deviceUpdate();
void seesawDronesUpdate();
void launchDrone();

void seesawDrawBoxOutline(int x, int y, int w, int h, unsigned int colour);
void seesawDrawSpeedMeter(void);


void countDownStart(countDownTimerStr *timer, long secs);
int  countDownUpdate(countDownTimerStr *timer);
void countDownActivate(countDownTimerStr *timer);
void countDownDraw(countDownTimerStr *timer, int x, int y);
//void seesawPrintChickenCount();

void seesawDrawBronzeSuccessScreen();
void seesawDrawSilverSuccessScreen();
void seesawDrawGoldSuccessScreen();

void seesawDrawIntro();
void seesawDrawFailScreen();
void seesawDrawSky();
void seesawDrawShadow(TextureType *shadow, int x, int y, int z, int size);
void seesawFree();

void seesawRestart();

void seesawUpdateAnims();






#endif