#e
#Title[͎ʁu_Ђ̎nՁv]
#Text[]
#ScriptVersion[2]

script_enemy_main
{//Enemy01
	let count=0;
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SyW擾
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(500);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-60,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		CutIn(YOUMU,"͎ʁu_Ђ̎nՁv",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);//蔻(e)o^
		SetCollisionB(GetX(),GetY(),24);//蔻(̓)o^
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetTexture(imgExRumia);	
		SetGraphicRect(1,1,64,64);
		SetGraphicScale(1,1);
		SetGraphicAngle(0,0,0);
		SetAlpha(255);
		DrawGraphic(GetX,GetY);
	}
	task shottask
	{
		wait(120);
		let angle=0;
		let graphic=0;
		loop
		{
			angle=atan2(GetPlayerY-(GetY-10),GetPlayerX-(GetX-20));
			loop(6)
			{
				graphic=78;
				loop(5)
				{
					CreateObjShot(3,angle,graphic,0);
					angle+=72;
					graphic--
				}
				wait(4);
			}
			wait(10);
		}
	}
	task CreateObjShot(let speed,let angle, let graphic, let delay)
	{
		let count=1;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetX-20+15*cos(angle), GetY-10+15*sin(angle));
		Obj_SetSpeed(obj, speed);
		Obj_SetAngle(obj, angle);
		ObjShot_SetGraphic(obj, 73);
		ObjShot_SetDelay(obj, delay);
		while(!Obj_BeDeleted(obj))
		{
			if(Obj_GetX(obj)<GetClipMinX)
			{
				loop(2)
				{
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj),rand(1,2),rand(70,110),graphic,0);
				}
				count--;
			}
			if(Obj_GetX(obj)>GetClipMaxX)
			{
				loop(2)
				{
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj),rand(1,2),rand(70,110),graphic,0);
				}
				count--;
			}
			if(Obj_GetY(obj)<GetClipMinY)
			{
				loop(2)
				{
					CreateShot01(Obj_GetX(obj),Obj_GetY(obj),rand(1,2),rand(70,110),graphic,0);
				}
				count--;
			}
			if(count<=0){ break; }
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}