script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=100;
		
		EnemyInitialize(20);
		MoveThread;
		EnemyDrawSystem(2);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(50);
		loop(3)
		{
			loop(3)
			{
				let p=GetAngleToPlayer;
				let speed=[1.5,3.2];
				let angle=p;
				let gra=15;
				let delay=2;
				ascent(a in 0..length(speed))
				{
					let spd=speed[a];
					SetEnemyShot02(GetX,GetY,0,angle,spd/60,spd,gra,delay);
				}
				wait(6);
			}
			wait(30);
		}
		wait(90);
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(50);
		let lp=0;
		let sp=0;
		loop(6)
		{
			let p=GetAngleToPlayer+180;
			let way=6+lp%2;
			let speed=1.2+sp;
			let angle=p;
			let gra=12;
			let delay=10;
			while(angle<p+360)
			{
				SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
				angle+=360/way;
			}
			lp++;
			sp+=0.2;
			wait(20);
		}
		local
		{
			let wide=8;
			let way=8;
			let p=GetAngleToPlayer;
			let speed=2;
			let angleA=p;
			let gra=31;
			let delay=0;
			while(angleA<p+360)
			{
				let angleB=angleA-wide/2;
				while(angleB<=angleA+wide/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angleB,gra,delay);
					angleB+=2;
				}
				angleA+=360/way;;
			}
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(50);
		local
		{
			let p=GetAngleToPlayer;
			let wide=24;
			let speed=1;
			let angle=p-wide/2;
			let gra=119;
			let delay=0;
			while(angle<=p+wide/2)
			{
				SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
				angle+=2;
			}
		}
		enemyargument=1;
		wait(20);
		let lp=0;
		loop(5)
		{
			let p=GetAngleToPlayer;
			let way=15;
			let speed=2.3;
			let angle=p;
			let gra=25;
			let delay=10;
			while(angle<p+360)
			{
				SetEnemyShot02(GetX,GetY,0,angle,speed/120,speed,gra,delay);
				angle+=360/way;
			}
			wait(20);
		}
	}
	
	
	task MoveThread
	{
		while(enemyspeed>0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>=0){enemyspeed-=0.07;}
			yield;
		}
		while(!enemyargument){yield;}
		let px=GetPlayerX;let py=GetPlayerY;
		loop
		{
			schMove(px,py,0.5);
			SetSpeed(enemyspeed);
			if(enemyspeed<3){enemyspeed+=0.07;}
			yield;
		}
	}
}