#e
#Title[zuUs̍U@v]
#Text[]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SyW擾
	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;
		bombtask;
		CutIn(YOUMU,"zuUs̍U@v",0,0,0,0,0);//XyJ[h\
	}
	@MainLoop
	{
		yield;
		count++;
	}
	@Finalize
	{
		loop(16)
		{
			CreateItem(ITEM_SCORE,GetX+rand(-30,30),GetY+rand(-30,30));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		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;
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(10,0);
				if(((GetPlayerX - GetX) ^ 2 + (GetPlayerY - GetY) ^ 2) ^ 0.5 <= (90)||count<180)
				{
					SetCollisionA(GetX(),GetY(),24);//蔻(e)o^
					SetCollisionB(GetX(),GetY(),24);//蔻(̓)o^
				}
			}
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy wall
{
	let count=255;
	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);
		if(count>0)
		{
			SetCollisionB(GetX(),GetY(),24);
		}
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		SetGraphicRect(155,26,189,60);
		SetAlpha(count);
		DrawGraphic(GetX(),GetY());
		if(count>0)
		{
			count--;
		}
	}
	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,10);
			}
			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;
		}
	}
}