#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//1way帺婡慱偄
	let ImgPata=GetArgument;//夋憸愝掕丄愒丄惵
	let imgEnemy="";
	if(ImgPata==1){imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_red.png";}
	else{imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_blue.png";}
	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(6,6);
			loop(40){yield;}
			Shot1(6,6);
		}
		case(0){//easy
			Shot1(4,3);
		}
		task Shot1(speed,loops){
			loop(loops){
				PlaySE(arrow01);
				CreateShot01(GetX,GetY,speed ,GetAngleToPlayer,65,10);
				speed-=0.4;
			}
		}
        }


        task Move{
		let angle  = 90;
		let Pangle = GetAngle;//揋堏摦妏搙
		let Nspeed= GetSpeed;	     //揋堏摦懍搙
		SetAngle(90);
		SetSpeed(Nspeed);
		SetAction(ACT_MOVE,300);
	      	loop(120){
			SetAngle(angle);
			angle+=Pangle;
			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());

	}
}