#東方弾幕風
#Title[構想「空間跳躍弾バイオレット」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let flag=0;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(1);
		SetDamageRate(0,0);
		SetMovePosition02(cx,cy-120,60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		SetDurableSpellCard;
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		movetask;
		subtask;
	}
	@MainLoop
	{
		yield;
		if(flag==0)
		{
			SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		}
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		if(flag==0)
		{
			SetGraphicRect(1,1,64,64);
			SetAlpha(255);
			DrawGraphic(GetX(),GetY());
		}
	}
	task shottask
	{
		let a=240;
		wait(420);
		loop(2)
		{
			shot(GetClipMaxX,GetClipMinY,2,-4,0,120,90,0);
			shot(GetClipMinX,GetClipMinY,2,0,4,120,0,0);
			wait(240);
		}
		wait(60);
		loop(2)
		{
			shot(GetClipMaxX,GetClipMaxY,2,0,-4,120,180,0);
			shot(GetClipMinX,GetClipMaxY,2,4,0,120,270,0);
			wait(240);
		}
		wait(60);
		shottask2;
		loop(2)
		{
			shot(GetClipMinX,GetClipMaxY,2,4,0,120,270,1);
			wait(120);
		}
		wait(60);
		loop(2)
		{
			shot(GetClipMinX,GetClipMinY,2,0,4,120,0,1);
			wait(120);
		}
		wait(90);
		loop(6)
		{
			let angle=rand(0,360);
			let x=rand(GetClipMinX,GetClipMaxX);
			let y=rand(GetClipMinY,GetClipMaxY);
			loop(120)
			{
				CreateShot01(x,y,2,angle,16,30);
				angle+=3;
			}
			wait(80);
		}
		wait(150);
		loop
		{
			let s=0;
			let xy=[GetPlayerX,GetPlayerY];
			CreateLaserA(s,xy[0],-120,1024,16,152,60);
			SetLaserDataA(s,0,90,0,0,0,0);
			SetShotKillTime(s,60);
			FireShot(s);
			CreateLaserA(s,-120,xy[1],1024,16,152,60);
			SetLaserDataA(s,0,0,0,0,0,0);
			SetShotKillTime(s,60);
			FireShot(s);
			wait(60);
			shot(xy[0],GetClipMinY,1,0,4,120,0,0);
			shot(xy[0],GetClipMaxY,1,0,-4,120,180,0);
			shot(GetClipMinX,xy[1],1,4,0,120,90,0);
			shot(GetClipMaxX,xy[1],1,-4,0,120,270,0);
			wait(a);
			if(a>21)
			{
				a-=20;
			}
		}
	}
	task shottask2
	{
		yield;
		loop(2)
		{
			shot(GetClipMaxX,GetClipMinY,2,-4,0,120,90,1);
			wait(120);
		}
		wait(60);
		loop(2)
		{
			shot(GetClipMaxX,GetClipMaxY,2,0,-4,120,180,1);
			wait(120);
		}
		wait(60);
	}
	task movetask
	{
		wait(60);
		Concentration01(60);
		wait(60);
		loop(60)
		{
			SetSpeed(10);
			SetAngle(25);
			wait(2);
		}
		wait(60);
		SetX(cx);
		SetY(cy);
		SetScore(30000);
		SetTimer(73);
		CutIn(YOUMU,"構想「空間跳躍弾バイオレット」",0,0,0,0,0);//スペルカード名表示
		SetEnemyMarker(false);
		flag=1;
	}
	task subtask
	{
		loop(300)
		{	
			if(GetX<45)
			{
				SetX(402)
			}
			else if(GetX>403)
			{
				SetX(46)
			}
			yield;
		}
		loop
		{	
			if(GetPlayerX<45)
			{
				SetPlayerX(402)
			}
			else if(GetPlayerX>403)
			{
				SetPlayerX(46)
			}
			if(GetPlayerY<33)
			{
				SetPlayerY(446)
			}
			else if(GetPlayerY>447)
			{
				SetPlayerY(34)
			}
			yield;
		}
	}
	function shot(let x,let y,let speed,let px,let py,let lo,let angle,let w)
	{
		loop(lo)
		{
			CreateShot01(x,y,speed,angle,16,0);
			x+=px;
			y+=py;
			if(w==1)
			{
				yield;
			}
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}