#東方弾幕風
#Title[「青き魔の館」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(1);
		SetDamageRate(0,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(93);
		SetGraphicRect(1,1,64,64);
		SetDurableSpellCard;
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		shottask2;
		movetask;
		CutIn(YOUMU,"「青き魔の館」",0,0,0,0,0);//スペルカード名表示
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{//読みこんだファイルを削除
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	
	@DrawLoop
	{
		//Exルーミア描画
		SetGraphicRect(64,64,127,127);
		SetAlpha(0);
		SetTexture(imgExRumia);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		loop
		{
			wait(3);
			if(GetTimer<=87)
			{
				shot2(s,120,0,30,1);
			}
			if(GetTimer<=70)
			{
				shot2(s,120,180,30,1);
				shot2(s,120,90,30,1);
				shot2(s,120,-90,30,1);
			}
			if(GetTimer<=55)
			{
				shot2(s,120,rand(-90,90),126,1);
			}
		}
	}
	task shottask2
	{
		let s=0;
		loop
		{
			wait(12);
			if(GetTimer<=30)
			{
				shot2(s,120,0,38,0.4);
			}
			if(GetTimer<=15)
			{
				shot2(s,120,0,102,4);
			}
		}
	}	
	task movetask
	{
		loop{
			let px=GetPlayerX;
			let py=GetPlayerY;
			yield;
			SetMovePosition02(px,py,30);
			if(GetTimer==71)
			{
				Concentration01(60);
				wait(60);
			}
			if(GetTimer==56)
			{
				Concentration01(60);
				wait(60);
			}
			if(GetTimer==31)
			{
				Concentration01(60);
				wait(60);
			}
			if(GetTimer==16)
			{
				Concentration01(60);
				wait(60);
			}
		}
	}
	function shot(let shotid,let shott,let angle,let tipe,let sp)
	{
		CreateShotA(shotid,GetX,GetY,10);
		SetShotDirectionType(ABSOLUTE);
		SetShotDataA(shotid,0,sp,angle,0,0,2,tipe);
		FireShot(shotid);
	}
	function shot2(let shotid,let shott,let angle,let tipe,let sp)
	{
		CreateShotA(shotid,GetX,GetY,10);
		SetShotDirectionType(ABSOLUTE);
		SetShotDataA(shotid,0,0,GetAngleToPlayer,0,0,2,tipe);
		SetShotDirectionType(PLAYER);
		SetShotDataA(shotid,shott,sp,angle,0,0,2,tipe);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}