#東方弾幕風
#Title[仮想「難攻不落の攻略法」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let wall=0;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(200);
		SetDamageRate(10,0);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(40);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(180);
		LoadGraphic(imgExRumia);
		LoadGraphic(GetCurrentScriptDirectory~".\img\shot\bullet.png");
		SetTexture(imgExRumia);	
		shottask;
		CutIn(YOUMU,"仮想「難攻不落の攻略法」",0,0,0,0,0);//スペルカード名表示
	}
	@MainLoop
	{
		yield;
		if(((GetPlayerX - GetX) ^ 2 + (GetPlayerY - GetY) ^ 2) ^ 0.5 <= (90)||count<180)
		{
			SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
			SetCollisionB(GetX(),GetY(),24);//当たり判定(体当たり)登録
		}
		count++;
	}
	@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 angle=rand(0,360);
		wait(120);
		loop(18)
		{
			CreateEnemyFromScript("wall",GetX,GetY,0,angle,angle);
			angle+=20;
		}
		loop
		{	
			wait(180);
			CreateLaserA(s,GetX,GetY,512,16,153,60);
			SetLaserDataA(s,0,GetAngleToPlayer,0,0,0,0);
			SetShotKillTime(s,120);
			FireShot(s);
		}
	}
	task shottask2
	{
		let s=0;
		loop
		{	
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy wall
{
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(500);
		SetDamageRate(0,0);
		SetInvincibility(60);
		SetTexture(GetCurrentScriptDirectory~".\img\shot\bullet.png");	
		shottask;
		movetask;
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		SetGraphicRect(155,26,189,60);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		wait(60);
		SetSpeed(0);
		loop
		{
			loop(72)
			{
				if(GetTimer<3)
				{
					loop(18)
					{
						CreateShot01(GetX,GetY,3,atan2(GetEnemyY-GetY,GetEnemyX-GetX)+rand(90,270),57,0);
					}
				}
				wait(8);
				CreateShot01(GetX,GetY,2,atan2(GetEnemyY-GetY,GetEnemyX-GetX)+180,57,0);
			}
			wait(120);
		}
	}
	task movetask
	{
		let count=0;
		let r=0;
		let angle=GetArgument;
		let flug=0;
		let a=-2;
		let a2=0.02;
		loop
		{
			SetX(GetEnemyX+r*cos(angle));
			SetY(GetEnemyY+r*sin(angle));
			angle+=a;
			a+=a2;
			if(r<90)
			{
				r++;
			}
			if(count%90==0)
			{
				a2*=-1;
			}
			count++;
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}