#東方弾幕風
#Title[迷符「惑いの森」]
#Text[試作]
#ScriptVersion[2]

script_enemy_main
{//Enemy01
	let count=0;
	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(500);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		CutIn(YOUMU,"幻壊「薄野の亡霊」",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),24);//当たり判定(体当たり)登録
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		let r=0;
		let r2=0;
		let angle=rand(0,360);
		let base =GetAngleToPlayer;
		wait(120);
		loop{
			r=rand(GetClipMinX,GetClipMaxX);
			r2=rand_int(0,1);
			if(r2==0)
			{
				r2=-1
			}
			wait(60);
			CreateLaserA(s,r,GetClipMinY,128,10,153,0);
			SetLaserDataA(s,0,angle,r2,0,1,90);
			FireShot(s);
			CreateLaserA(s,r,GetClipMinY,128,10,160,0);
			SetLaserDataA(s,0,angle+180,r2,0,1,90);
			FireShot(s);
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}