script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=120;
		
		EnemyInitialize(10);
		MoveThread;
		EnemyDrawSystem(0);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(40);
		let sp=0;
		loop(9)
		{
			let way=4;
			let p=GetAngleToPlayer;
			
			let speed=[2+sp,3+sp];
			let angle=p;
			let gra=81;
			let delay=10;
			while(angle<p+360)
			{
				ascent(a in 0..length(speed))
				{
					SetEnemyShot01(GetX,GetY,speed[a],angle,gra,delay);
				}
				angle+=360/way;
			}
			sp+=0.4;
			wait(4);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(40);
		local
		{
			let wide=10;
			let way=6;
			
			let p=GetAngleToPlayer;
			let ag=p;
			while(ag<p+360)
			{
				let speed=2.5;
				let angle=ag-wide/2;
				let gra=28;
				let delay=10;
				while(angle<=ag+wide/2+1)
				{
					SetEnemyShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
					angle+=2;
				}
				ag+=360/way;
			}
		}
		enemyargument=1;
		while(GetY<=350)
		{
			let p=GetAngleToPlayer;
			let wide=340;
			let way=3;
			
			let speed=1.5;
			let angle=p-wide/2;
			let gra=12;
			let delay=12;
			while(angle<=p+wide/2+1)
			{
				SetEnemyShot02(GetX,GetY,0,angle,speed/120,speed,gra,delay);
				angle+=wide/(way-1);
			}
			wait(10);
		}
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(50);
		let r=1;
		if(GetX<cenX){r=-r;}
		loop(2)
		{
			let sp=0;
			let px=GetPlayerX;
			let py=GetPlayerY;
			loop(8)
			{
				let wide=100;
				let way=7;
				
				let sx=GetX+20*r;
				let p=atan2(py-GetY,px-sx);
				let speed=2.5+sp;
				let angle=p-wide/2;
				let gra=83;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot02(sx,GetY,0,angle,speed/30,speed,gra,delay);
					angle+=wide/(way-1);
				}
				sp+=0.1;
				wait(3);
			}
			r=-r;
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.07;}
			yield;
		}
		enemyangle=GetAngleToPlayer;
		loop
		{
			if(GetY<=350){schMove(GetPlayerX,GetPlayerY,1.1);}
			SetSpeed(enemyspeed);
			if(enemyspeed<4.5){enemyspeed+=0.05;}
			yield;
		}
	}
}