#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//5way愒抏
	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(50){yield;}
		alternative(Level)
		case(1){//hard
			Shot1(-60,  1,6,5);
		}
		case(0){//easy
			Shot1(-0.8,0.4,3,1);
		}
		task Shot1(angle,Pangle,speed,loops){
			loop(loops){
				let Nangle=angle;
				PlaySE(arrow01);
				loop(loops){
					loop(5){
						CreateShot01(GetX,GetY,speed ,GetAngleToPlayer+Nangle,65,10);
						Nangle+=Pangle;
					}
					Nangle+=24;
				}
				speed-=1;
			}
		}
        }


        task Move{
		let angle = GetAngle;//揋堏摦妏搙
		let speed = GetSpeed;	     //揋懍搙惂屼
		let Nspeed= GetSpeed;	     //揋堏摦懍搙
		SetAngle(angle);
		SetAction(ACT_MOVE,60);
	      	loop(30){
			Nspeed-=speed/30;
			SetSpeed(Nspeed);
			yield;
		}
	      	loop(60){yield;}
		SetAngle(-angle);
		SetAction(ACT_MOVE,240);
	      	loop(60){
			Nspeed+=2.2/60;
			SetSpeed(Nspeed);
			yield;
		}

      
        }
 
	

	@Finalize
	{
		if(BeVanished==true){return;}
		loop(2){
			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());

	}
}