#東方弾幕風
#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(600);
		SetDamageRate(10,8);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		shottask2;
		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 x=0;
		let y=0;
		wait(120);
		Concentration01(60);
		wait(60);
		loop
		{
			wait(30);
			x=GetClipMinX+24;
			loop(4)
			{
				y=GetClipMinY;
				loop(23)
				{
					shot(s,x,y);
					y+=20;
					wait(2);
				}
				x+=112
			}
		}
	}
	task shottask2
	{
		let s=0;
		let x=0;
		let y=0;
		wait(180);
		loop
		{
			wait(30);
			y=GetClipMinY+56;
			loop(4)
			{
				x=GetClipMinX;
				loop(20)
				{
					shot(s,x,y);
					x+=20;
					wait(2);
				}
				y+=112
			}
		}
	}
	function shot(let shotid,let shotx,let shoty)
	{
		CreateShotA(shotid,shotx,shoty,10);
		SetShotDirectionType(SEQUENCE);
		SetShotDataA(shotid,0,0,0,0,0,2,16);
		SetShotDataA(shotid,120,rand(0.5,1.5),rand(GetAngleToPlayer+60,GetAngleToPlayer-60),0.1,0,2,16);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}