#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//摿庩1way帺婡慱偄
	let ImgPata=GetArgument;//夋憸愝掕丄愒丄惵
	let imgEnemy="";
	let col = 65;
	if(ImgPata==1){imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_red.png";}
	else{
		imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_blue.png";
		col = 70;
	}
	let DrawAngle=0;

	#include_function".\lib\lib_common.txt"
	#include_function".\lib\lib_anime_Zako.txt"
	@Initialize
	{
		SetLife(10);
                SetInvincibility(20);
                InitializeAction();
                Tmain;
	}
	
	@MainLoop
	{
                if(GetY<cmy-32||GetY>cmY+32||GetX<cmx-32||GetX>cmX+32){VanishEnemy();}
		SetCollisionA(GetX(),GetY(),32);//摉偨傝敾掕(帺抏)搊榐
		yield;
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
	}

        task Tmain{
		Move;
		loop(10){yield;}
		alternative(Level)
		case(1){//hard
			Shot1();
		}
		case(0){//easy
			if(ImgPata==2){Shot2();}
		}
		task Shot1(){
			loop(2){
				let angle= GetAngleToPlayer;
				PlaySE(arrow01);
				CreateShot01(GetX+10*cos(angle+16),GetY+10*sin(angle+16),4,angle,col,10);
				CreateShot01(GetX+10*cos(angle-16),GetY+10*sin(angle-16),4,angle,col,10);
				CreateShot01(GetX+15*cos(angle),GetY+15*sin(angle),4,angle,col,10);
				loop(40){yield;}
			}
		}

		task Shot2(){
			let angle= GetAngleToPlayer;
			PlaySE(arrow01);
			CreateShot01(GetX+15*cos(angle),GetY+15*sin(angle),2,angle,col,10);
		}
        }


        task Move{
		let angle = GetAngle;
		let Nspeed= GetSpeed;	     //揋堏摦懍搙
		let speed = GetSpeed;	     
		SetAngle(GetAngle);
		SetSpeed(Nspeed);
		SetAction(ACT_MOVE,400);
	      	loop(20){
			Nspeed-=speed/20;
			SetSpeed(Nspeed);
			yield;
		}
	      	loop(30){yield;}
	      	loop(30){
			Nspeed+=speed/30;
			SetSpeed(Nspeed);
			yield;
		}
      
        }
 
	

	@Finalize
	{
		if(BeVanished==true){return;}
		CreateShotFromScript("I_Item",GetX+rand(-15,15),GetY+rand(-15,15),0,0,0,0);
		if(GetArgument==1){
			CreateShotFromScript("P_Item",GetX,GetY,0,0,0,0);
		}
		if(GetArgument==2){
			CreateShotFromScript("TenItem",GetX,GetY,0,0,0,0);
		}

	}
	
	@DrawLoop
	{//昤夋

		DrawBoss(imgEnemy);
		DrawGraphic(GetX(),GetY());

	}
}