#include "enemy.h"
#include "sequencer.h"
#include "stage.h"
#include "player.h"

int currentEvent;

void SetCurrentEvent(int eventNumber)
{
	currentEvent = eventNumber;
}

void InitSequencer ()
{
	currentEvent = 0;
}

void UpdateSequencer ()
{
	if (stages[currentStage].sequence[currentEvent].type >= 0 && stages[currentStage].sequence[currentEvent].type <= 11)
	{
		for (int a = 0; a < NUM_ENEMIES; a++)
		{
			if(enemies[a].active == false)
			{
				enemies[a].active = true;
				enemies[a].type = stages[currentStage].sequence[currentEvent].type;
				enemies[a].xDirection = stages[currentStage].sequence[currentEvent].xDirection;
				enemies[a].yDirection = stages[currentStage].sequence[currentEvent].yDirection;
				enemies[a].X  = stages[currentStage].sequence[currentEvent].X;
				enemies[a].Y  = stages[currentStage].sequence[currentEvent].Y;
				enemies[a].manbearpiglife = 50;
				enemies[a].enemyHP = 3;

				break;
			}
		}
		SetCurrentEvent(currentEvent+1);
	}
	else if ( stages[currentStage].sequence[currentEvent].type == SEQ_GOTO)
	{
		SetCurrentEvent(stages[currentStage].sequence[currentEvent].X);
	}
	else if ( stages[currentStage].sequence[currentEvent].type == SEQ_LINE)
	{
		if(player.X>stages[currentStage].sequence[currentEvent].X)
			SetCurrentEvent(currentEvent+1);
	}
}
