script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=250;
		
		EnemyInitialize(50);
		MoveThread;
		EnemyDrawSystem(1);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(30);
		loop(2)
		{
			let s=0;
			loop(10)
			{
				let p=GetAngleToPlayer;
				let speed=2+s;
				let angle=p;
				let gra=71;
				let delay=6;
				SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
				s+=0.2;
				wait(4);
			}
			wait(10);
			let s=0;
			let p=GetAngleToPlayer;
			let wide=40;
			let way=3;
			loop(3)
			{
				let speed=2.4+s;
				let angle=p-wide/2;
				let gra=31;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
					angle+=wide/(way-1);
				}
				s+=0.4;
				wide+=45;
				way+=2;
				wait(7);
			}
			wait(60);
		}
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(30);
		loop(2)
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			let sx_=[GetX-30,GetX+30];
			let sy_=GetY;
			loop(10)
			{
				let way=4;
				let wide=150;
				let sx=[GetX-30,GetX+30];
				let speed=2;
				let gra=82;
				let delay=10;
				ascent(a in 0..2)
				{
					let p=atan2(py-sy_,px-sx_[a]);
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
						angle+=wide/(way-1);
					}
				}
				wait(2);
			}
			wait(10);
			
			let px=GetPlayerX;
			let py=GetPlayerY;
			let i=0;
			let sp=0;
			loop(6)
			{
				let r=1;
				let sx=[GetX-30,GetX+30];
				let speed=3.5-sp;
				let gra=25;
				let delay=5;
				ascent(a in 0..2)
				{
					let angle=atan2(py-GetY,px-sx[a])+i*r;
					SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
					r=-r;
				}
				
				i+=1;
				sp+=0.1;
				wait(2);
			}
			wait(60);
		}
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(30);
		loop(2)
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			loop(6)
			{
				let r=-1;
				let sx=[GetX-30,GetX+30];
				let speed=1.6;
				let gra=30;
				let delay=5;
				ascent(a in 0..2)
				{
					let wide=24;
					let p=atan2(py-GetY,px-sx[a]);
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						SetEnemyShot02(sx[a],GetY,-speed,angle,speed/60,speed,gra,delay);
						angle+=3;
					}
					r=-r;
				}
				wait(3);
			}
			let px=GetPlayerX;
			let py=GetPlayerY;
			let sx_=GetX;
			let sy_=GetY;
			loop(10)
			{
				let wide=70;
				let way=5;
				let speed=[3];
				let gra=84;
				let delay=10;
				let p=atan2(py-sy_,px-sx_);
				let angle=p-wide/2;
				while(angle<=p+wide/2+1)
				{
					ascent(s in 0..length(speed))
					{
						SetEnemyShot02(GetX,GetY,0,angle,speed[s]/20,speed[s],gra,delay);
					}
					angle+=wide/(way-1);
				}
				wait(2);
			}
			wait(70);
		}
	}
	
	
	task MoveThread
	{
		loop
		{
			schMove(cenX,minY-120,1.1);
			SetSpeed(enemyspeed);
			if(enemyspeed>=1){enemyspeed-=0.03;}
			yield;
		}
	}
}