#e
#Title[uG^[\[hv]
#Text[hXy]
#Image[]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]


script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGV[̒SxW擾;
	let step=1;
	let imgExRumia="script\ExRumia\img\ExRumia.png";
	let imgExRumiaBack="script\ExRumia\img\ExRumiaBack.png";
	let Timer=[GetCurrentScriptDirectory~"se\cursor15_b.wav",GetCurrentScriptDirectory~"se\cursor15_a.wav"];
	let timestart=0;
	let seNumber=2;
	let SE=[GetCurrentScriptDirectory~"se\arrow01.wav",
	        GetCurrentScriptDirectory~"se\eco02_b.wav",
	        GetCurrentScriptDirectory~"se\eco00.wav"];
	@Initialize
	{
		SetScore(100000);//XyJ[h{[iX50000ɐݒ
		SetLife(216);//Ct280ɐݒ
		SetDamageRate(1,0);//_[W10%ɐݒ
		SetTimer(1000);//Ԑ60bɐݒ
		SetRateScoreSystemEnable(false);

		SetGraphicRect(1,1,64,64);//`挳`ݒ
		SetInvincibility(30);//G30t[Gɂ
		LoadGraphic(imgExRumia);//摜uimg\ExRumia.pngvǂ݂		
		LoadGraphic(imgExRumiaBack);
		ascent(i in 0..seNumber){LoadSE(SE[i]);}
		LoadSE(Timer[0]);
		LoadSE(Timer[1]);
		SetColor(255,64,255);
		SetMovePosition02(cx-60*step,120,60);//W(cx-60*step,120)60t[Ĉړ
		Concentration01(120);
		CutIn(KOUMA,"uG^[\[hv",0,0,0,0,0);//XyJ[h\
	}
	
	@MainLoop
	{
		if(GetTimer==9 && timestart==0){Timecounter;timestart++;}
		SetColor(255,64,255);
		yield;
		if(count==90)
		{
			SetMovePosition02(cx-60*step,120,60);
			Concentration01(120);
		}
		if(count==150)
		{//[U[o
			let laser=0;
			CreateLaserB(laser,0,30,PURPLE02,0);
			SetShotKillTime(laser,180);
			if(step==1){SetLaserDataB(laser,0,10,0,0,0,0,0,0);}
			else if(step==-1){SetLaserDataB(laser,0,10,0,0,180,0,180,0)};		
			SetLaserDataB(laser,60,0,NULL,0,NULL,0,NULL,0);
			SetLaserDataB(laser,90,0,NULL,0,NULL,-3.0*step,NULL,-3.0*step);
				
			let i=60;
			while(i<90)
			{
				let j=0;
				while(j<400)
				{//[U[ɒeo^
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,90,0,0,1.5,RED02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,270,0,0,1.5,BLUE02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=5;
			}
			SetLaserDataB(laser,180,0,NULL,0,NULL,0,NULL,0);
			
			i=90;
			while(i<180)
			{
				let j=0;
				while(j<400)
				{
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,270,0,0,1.5,YELLOW02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,90,0,0,1.5,GREEN02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=4;
			}		
			FireShot(laser);
		}
		if(count==210)
		{
			SetMovePosition03(cx,240,15,10);
		}	
		if(count==300)
		{
			SetMovePosition03(cx+60*step,120,15,10);
			Concentration01(120);
		}
		if(count==360)
		{
			let laser=0;
			CreateLaserB(laser,0,30,PURPLE02,0);
			SetShotKillTime(laser,180);
			if(step==1){SetLaserDataB(laser,0,10,0,0,180,0,180,0);}
			else if(step==-1){SetLaserDataB(laser,0,10,0,0,0,0,0,0)};		
			SetLaserDataB(laser,60,0,NULL,0,NULL,0,NULL,0);
			SetLaserDataB(laser,90,0,NULL,0,NULL,3.0*step,NULL,3.0*step);
				
			let i=60;
			while(i<90)
			{
				let j=0;
				while(j<400)
				{
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,270,0,0,1.5,ORANGE02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,90,0,0,1.5,AQUA02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=5;
			}
			SetLaserDataB(laser,180,0,NULL,0,NULL,0,NULL,0);
			
			i=90;
			while(i<180)
			{
				let j=0;
				while(j<400)
				{
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,90,0,0,1.5,PURPLE02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,270,0,0,1.5,WHITE02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=4;
			}		
			FireShot(laser);
		}
		if(count==420)
		{
			SetMovePosition03(cx,240,15,10);
		}	
		if(count==540)
		{
			SetMovePosition03(cx-180*step,16,15,10);
			Concentration01(120);
		}
		if(count==600)
		{
			let laser=0;
			CreateLaserB(laser,0,30,PURPLE02,0);
			SetShotKillTime(laser,90);
			if(step==1){SetLaserDataB(laser,0,10,0,0,0,0,0,0);}
			else if(step==-1){SetLaserDataB(laser,0,10,0,0,180,0,180,0);}	
			SetLaserDataB(laser,60,0,NULL,0,NULL,0,NULL,0);			
			let i=60;
			while(i<90)
			{
				let j=0;
				while(j<400)
				{
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,90,0,0,1.5,RED02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,270,0,0,1.5,GREEN02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=4;
			}
			FireShot(laser);
		}
		if(count==660)
		{
			SetMovePosition03(cx-180*step,400,15,10);
		}
		if(count==660)
		{
			let laser=0;
			CreateLaserB(laser,0,30,PURPLE02,0);
			SetShotKillTime(laser,170);
			if(step==1){SetLaserDataB(laser,0,3,0,0,45,0,45,0);}
			else if(step==-1){SetLaserDataB(laser,0,3,0,0,135,0,135,0);}		
			SetLaserDataB(laser,60,2.5,NULL,0,NULL,-3*step,NULL,-3*step);			
			let i=120;
			while(i<170)
			{
				let j=0;
				while(j<400)
				{
					let shot=1;
					CreateShotA(shot,0,0,30);
					if(step==1){SetShotDataA(shot,0,1.5,270,0,0,1.5,BLUE02);}
					else if(step==-1){SetShotDataA(shot,0,1.5,90,0,0,1.5,YELLOW02);}
					AddShot(i,laser,shot,j);
					j+=40;
				}
				i+=5;
			}
			FireShot(laser);
		}
		if(count==720)
		{
			SetMovePosition02(cx+180*step,18,60);
		}
		if(count==810)
		{
			step*=-1;
			count=89;
		}
		SetCollisionA(GetX(),GetY(),32);//蔻(e)o^
		SetCollisionB(GetX(),GetY(),24);//蔻(̓)o^
		count++;			
	}
	
	@Finalize
	{//ǂ݂񂾃t@C폜
		DeleteGraphic(imgExRumia);	
		DeleteGraphic(imgExRumiaBack);
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	
	@DrawLoop
	{
		//Ex[~A`
		DrawText("E.Frandle",50,40,18,255);
		SetFontColor(255,100,150,50,80,46);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetAlpha(255);
		SetTexture(imgExRumia);
		if(int(GetSpeedX())==0){SetGraphicRect(64,1,127,64);}
		else if(GetSpeedX()>0){SetGraphicRect(192,1,255,64);}
		else if(GetSpeedX()<0){SetGraphicRect(128,1,191,64);}
		DrawGraphic(GetX(),GetY());
	}

	task Timecounter{
		function Wait(let frame){loop(frame){yield};}
		
		loop(7){
			PlaySE(Timer[0]);
			Wait(60);
			}
		loop(3){
			PlaySE(Timer[0]);
			PlaySE(Timer[1]);
			Wait(60);
			}
		}
}