script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=500;
		
		EnemyInitialize(180);
		MoveThread;
		EnemyDrawSystem(1);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(20);
		let i=0;
		let wide=3600+300;
		let sp=0;
		loop(30)
		{
			let ag=[i,180-i];
			ascent(a in 0..2)
			{
				let v=50;
				let sx=GetX+v*cos(ag[a]);
				let sy=GetY+(v/2)*sin(ag[a]);
				let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
				let speed=[3.5,3.4];
				let gra=87;
				let delay=10;
				ascent(b in 0..length(speed))
				{
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SetEnemyShot01(sx,sy,speed[b]+sp,angle,gra,delay);
						angle+=wide/2;
					}
				}
			}
			sp+=0.05;
			i+=6;
			wide-=20;
			wait(5);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(40);
		let i=0;
		let wide=30;
		let wideB=40;
		let sp=0;
		let px=GetPlayerX;
		let py=GetPlayerY;
		loop(40)
		{
			let ag=[i,180-i];
			ascent(a in 0..2)
			{
				let v=50;
				let sx=GetX+v*cos(ag[a]);
				let sy=GetY+(v/2)*sin(ag[a]);
				let p=atan2(py-sy,px-sx);
				let speed=[3.5,3.2];
				let gra=87;
				let delay=10;
				ascent(b in 0..length(speed))
				{
					let angleA=p-wideB/2;
					while(angleA<=p+wideB/2+1)
					{
						let angleB=angleA-wide/2;
						while(angleB<=angleA+wide/2+1)
						{
							SetEnemyShot01(sx,sy,speed[b]+sp,angleB,gra,delay);
							angleB+=wide;
						}
						angleA+=wideB;
					}
				}
			}
			
			sp+=0.05;
			i+=6;
			wide+=2;
			wideB+=1;
			wait(3);
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(50);
		let r=1;
		loop(3)
		{
			let sx=[GetX+50,GetX-50];
			ascent(a in 0..2)
			{
				let i=GetAngleToPlayer;
				let sp=0;
				loop(10)
				{
					let way=15;
					let speed=3.5+sp;
					let angle=i;
					let gra=27;
					let delay=10;
					while(angle<i+360)
					{
						SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
						angle+=360/way;
					}
					wait(4);
					i+=2.5*r;
					sp+=0.05;
				}
				wait(15);
				r=-r;
			}
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0){enemyspeed-=0.05;}
			yield;
		}
		loop
		{
			schMove(cenX,maxY+120,1.1);
			SetSpeed(enemyspeed);
			if(enemyspeed<4.5){enemyspeed+=0.025;}
			yield;
		}
	}
}