
script_enemy_main
{
	#include_script".\..\..\EnemyBossSystem.txt";
	#include_script".\Utsuho_AnimeLib.txt";
	
	tex_enemy=filedir~"Utsuho_Main.png";
	tex_spellbg=filedir~"Utsuho_SpellBG.png";
	
	bg_rect=[0,0,800,600];
	
	let f_caution=GetCurrentScriptDirectory~"Utsuho_Caution.txt";
	
	@Initialize
	{
		point=390;
		SetLife(1100);
		SetTimer(57);
		EnemyBossInitialize;
		SetAnimetion(tex_enemy);
	}
	@MainLoop{EnemyBossMainLoopSystem(50,invincible);yield;}
	@DrawLoop{EnemyBossDrawLoop;}
	@Finalize{EnemyBossFinalize;}
	
	
	
	task MainThread_Standard{}
	task MainThread_Advanced{}
	
	task MainThread_Unlimited
	{
		yield;
		SetMovePositionHermite(cenX,minY+160,0,0,0,0,100);
		SetAction(ACT_MOVE,100);
		SetSpellCard("光輪「完全たる幻日環」",50);
		CreateEnemyFromFile(f_caution,cenX,cenY,0,0,0);
		wait(120);
		SetAction(ACT_SUN,150);
		let bx=cenX;
		let by=minY-100;
		local
		{
			let size=1;
			CreateShotFromScript("Sun",bx,by,0,0,120,size);
		}
		State;
		wait(100);
		Sub;
		let r=1;
		if(rand_int(0,1)){r=-r;}
		loop
		{
			SetMovePositionHermite(cenX+rand(-80,80),minY+rand(150,170),0,0,0,0,100);
			SetAction(ACT_MOVE,100);
			wait(140);
			
			SetAction(ACT_SUN,150);
			let speed=6;
			let p=rand(0,360);
			let lp=0;
			loop(24)
			{
			//	if(lp>16){p=rand(0,360);}
				let way=36;
				let sy=GetY-30;
				let angle=p;
				let gra=41;
				let delay=10;
				while(angle<p+360)
				{
					CreateShot02(GetX,sy,0,angle,speed/30,speed,gra,delay);
					angle+=360/way;
				}
				wait(5);
				lp++;
				speed/=1.05;
			}
			wait(20);
		}
		
		task State
		{
			wait(120);
			Explosion01(bx,by,2,0.4,120);
			let v=0.5;
			loop
			{
				let p=atan2(GetPlayerY-by,GetPlayerX-bx)+180;
				let mx=GetPlayerX+v*cos(p);
				let my=GetPlayerY+v*sin(p);
				SetPlayerX(mx);
				SetPlayerY(my);
				yield;
			}
		}
		
		task Sub
		{
			let i=0;
			let lp=0;
			loop
			{
				let way=3;
				let p=[90+i,90-i];
				ascent(a in 0..2)
				{
					let ag=p[a];
					while(ag<p[a]+360)
					{
						let v=260;
						let sx=bx+v*cos(ag);
						let sy=by+v*sin(ag);
						
						let speed=2.5;
						let angle=ag-120*(lp%3);
						let gra=19;
						let delay=20;
						CreateShot02(sx,sy,0,angle,speed/180,speed,gra,delay);
						ag+=360/way;
					}
				}
				i+=0.97;
				lp++;
				wait(1);
			}
		}
	}
	
}

#include_script".\Utsuho_SunShot.txt"
