script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=600;
		
		EnemyInitialize(340);
		MoveThread;
		EnemyDrawSystem(3);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(5);
		Sub;
		let p=160;
		loop(60)
		{
			let sx=[GetX+40,GetX-40];
			ascent(a in 0..2)
			{
				let wide=20;
				let way=4;
				let speed=5;
				let ag=[90-p,90+p];
				let gra=87;
				let delay=10;
				let angle=ag[a]-wide/2;
				while(angle<=ag[a]+wide/2+1)
				{
					SetEnemyShot02(sx[a],GetY,0,angle,speed/20,speed,gra,delay);
					angle+=wide/(way-1);
				}
			}
			p-=2;
			wait(4);
		}
		task Sub
		{
			let r=1;
			if(GetX<cenX){r=-r;}
			loop(6)
			{
				let p=GetAngleToPlayer;
				loop(10)
				{
					let wide=15;
					let sx=GetX+40*r;
					let speed=3.5;
					let angle=p-wide/2;
					let gra=63;
					let delay=10;
					while(angle<=p+wide/2+1)
					{
						SetEnemyShot01(sx,GetY,speed,angle,gra,delay);
						angle+=wide;
					}
					wait(2);
				}
				r=-r;
				wait(25);
			}
		}
		enemyargument=1;
		wait(30);
		loop
		{
			let way=24;
			let p=GetAngleToPlayer;
			
			let speed=3;
			let angle=p;
			let gra=151;
			let delay=10;
			while(angle<p+360)
			{
				SetEnemyShot02(GetX,GetY,0,angle,speed/60,speed,gra,delay);
				angle+=360/way;
			}
			wait(40);
		}
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(20);
		let lp=0;
		loop(4)
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			let bx=[GetX+20,GetX-20];let by=GetY;
			let sp=0;
			loop(15)
			{
				
				let sx=[GetX+20,GetX-20];
				ascent(a in 0..2)
				{
					let p=atan2(py-by,px-bx[a]);
					let wide=140;
					let way=6+lp%2;
					let speed=3+sp;
					let gra=87;
					let delay=10;
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SetEnemyShot02(sx[a],GetY,0,angle,speed/60,speed,gra,delay);
						angle+=wide/(way-1);
					}
				}
			//	sp+=0.05;
				wait(2);
			}
			lp++;
			wait(20);
		}
		enemyargument=1;
		wait(40);
		loop
		{
			let p=GetAngleToPlayer+rand(-20,20);
			
			let wide=[60,8];
			let way=3;
			let speed=3;
			let ag=p-wide[0]/2;
			let gra=151;
			let delay=10;
			while(ag<=p+wide[0]/2+1)
			{
				let angle=ag-wide[1]/2;
				while(angle<=ag+wide[1]/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=2;
				}
				ag+=wide[0]/(way-1);
			}
			
			wait(20);
		}
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(10);
		let r=1;
		if(GetX<cenX){r=-r;}
		let i=0;
		let sp=0;
		loop(40)
		{
			let wide=8;
			let way=2;
			let sx=[GetX+20,GetX-20];
			let p=[90+i,90-i];
			ascent(a in 0..2)
			{
				let speed=4.5+sp;
				let ag=p[a];
				let gra=30;
				let delay=10;
				while(ag<p[a]+360)
				{
					let angle=ag-wide/2;
					while(angle<=ag+wide/2+1)
					{
						SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
						angle+=2;
					}
					ag+=360/way;
				}
			}
			sp+=-0.1;
			i+=21*r;
			wait(5);
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		wait(170);
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.05;}
			yield;
		}
		loop
		{
			schMove(cenX,minY-120,1.1);
			SetSpeed(enemyspeed);
			if(enemyspeed<1.5){enemyspeed+=0.025;}
			yield;
		}
	}
}