
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Sakuya_AnimeLib.txt";
	
	tex_enemy=filedir~"Sakuya_Main.png";
	tex_spellbg=filedir~"Sakuya_SpellBG.png";
	
	bg_rect=[0,0,768,512];
	
	boss_bgposx=cenX-90;
	boss_bgposy=cenY+30;
	
	@Initialize
	{
		point=420;
		SetLife(900);
		SetTimer(57);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard
	{
		yield;
		SetMovePositionHermite(cenX,minY+120,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("刻刹「デイライトフォルクス」",66);
		wait(120);
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetAction(ACT_SHOT_A,50);
			local
			{
				let p=GetAngleToPlayer;
				let way=15;
				let wide=200;
				let speed=7.5;
				let angle=p-wide/2;
				let delay=10;
				while(angle<=p+wide/2+1)
				{
					let gra=175;
					CreateShot01(GetX,GetY,speed,angle,gra,delay);
					
					let leng=500;
					let width=10;
					gra=47;
					CreateLaser01(GetX,GetY,speed,angle,leng,width,gra,delay);
					angle+=wide/(way-1);
				}
				wait(15);
				local
				{
					let file=GetCurrentScriptDirectory~"Sakuya_Familier01.txt";
					let speed=3.4;
					let angle=p-wide/2;
					while(angle<=p+wide/2+1)
					{
						CreateEnemyFromFile(file,GetX,GetY,speed,angle,r);
						angle+=wide;
					}
				}
			}
			wait(200);
			SetAction(ACT_SHOT_B,140);
			local
			{
				let leng=[100,60];
				let lp=0;
				let wide=50.1;
				let i=rand(0,360);
				let L=21;
				loop(L)
				{
					local
					{
						let sx=GetX+leng[lp%length(leng)]*cos(i);
						let sy=GetY+leng[lp%length(leng)]*sin(i);
						let p=atan2(GetPlayerY-sy,GetPlayerX-sx);
						let angle=p;
						let gra=175;
						let delay=15;
						let speed=4;
						while(speed>=2)
						{
							CreateShot02(sx,sy,0,angle,speed/60,speed,gra,delay);
							speed/=1.2;
						}
						
						let gra=169;
						let speed=2.5;
						let angle=p-absolute(wide)/2;
						while(angle<=p+absolute(wide)/2+1)
						{
							CreateShot02(sx,sy,0,angle,speed/60,speed,gra,delay);
							angle+=absolute(wide);
						}
					}
					i+=(360/L)*5;
					lp++;
					wide-=4;
					wait(7);
					
				}
			}
			wait(60);
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(110,130),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(100);
			r=-r;
		}
		
	}
	
	task MainThread_Advanced{}
	task MainThread_Unlimited{}
	
}