script_enemy_main
{
	#include_script".\..\..\EnemySystem.txt";
	
	@Initialize
	{
		point=300;
		
		EnemyInitialize(40);
		MoveThread;
		EnemyDrawSystem(1);
	}
	@MainLoop{EnemyMainLoopSystem(30);yield;}
	@DrawLoop{}
	@Finalize{EnemyFinalize;}
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Standard
	{
		wait(60);
		loop(2)
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			loop(6)
			{
				let way=2;
				let sx=[GetX+20,GetX-20];
				ascent(a in 0..2)
				{
					let p=atan2(py-GetY,px-sx[a]);
					let speed=[4.4,3.8];
					let gra=84;
					let delay=10;
					let wide=4;
					ascent(s in 0..length(speed))
					{
						let angle=p-wide/2;
						while(angle<=p+wide/2+0.1)
						{
							SetEnemyShot01(sx[a],GetY,speed[s],angle,gra,delay);
							angle+=wide/(way-1);
						}
						wide+=2;
					}
				}
				wait(3);
			}
			wait(15);
			
			let p=GetAngleToPlayer;
			loop(7)
			{
				let speed=[3.4,2.7,2];
				let angle=p;
				let gra=60;
				let delay=10;
				ascent(a in 0..length(speed))
				{
					SetEnemyShot01(GetX,GetY,speed[a],angle,gra,delay);
				}
				wait(3);
			}
			
			wait(60);
		}
		enemyargument=1;
	}
	
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Advanced
	{
		wait(30);
		local
		{
			let px=GetPlayerX;
			let py=GetPlayerY;
			let i=0;
			loop(24)
			{
				let sx=[GetX-40,GetX+40];
				let speed=4;
				let gra=114;
				let delay=10;
				ascent(a in 0..2)
				{
					let p=atan2(py-GetY,px-sx[a]);
					let ag=[p+i,p-i];
					let angle=ag[a];
					
					SetEnemyShot01(sx[a],GetY,speed,angle,gra,delay);
				}
				i+=0.3;
				wait(2);
			}
			let px=GetPlayerX;
			let py=GetPlayerY;
			loop(5)
			{
				let wide=70;
				let way=5;
				
				let sx=[GetX-40,GetX+40];
				let speed=4;
				let gra=58;
				let delay=10;
				ascent(a in 0..2)
				{
					let p=atan2(py-GetY,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(3);
			}
		}
		enemyargument=1;
	}
	
	
	//---------------------------------------------------------------
	//---------------------------------------------------------------
	task MainThread_Unlimited
	{
		wait(50);
		let sp=0;
		loop(4)
		{
			let p=GetAngleToPlayer;
			local
			{
				let wide=35;
				let wideB=6;
				let way=3;
				let speed=2.5-sp;
				let gra=25;
				let delay=10;
				let ag=p-wide/2;
				while(ag<=p+wide/2+1)
				{
					let angle=ag-wideB/2;
					while(angle<=ag+wideB/2+1)
					{
						SetEnemyShot01(GetX,GetY,speed,angle,gra,delay);
						angle+=1;
					}
					ag+=wide/(way-1);
				}
			}
			sp+=0.5;
			wait(40);
		}
		enemyargument=1;
	}
	
	
	task MoveThread
	{
		while(enemyargument==0)
		{
			SetSpeed(enemyspeed);
			if(enemyspeed>0.2){enemyspeed-=0.07;}
			yield;
		}
		loop
		{
			SetSpeed(enemyspeed);
			if(enemyspeed<2){enemyspeed+=0.025;}
			yield;
		}
	}
}