#include_script".\Item02.txt"
#include_script".\Item04.txt"
script_enemy_main
{//全方位黄弾
	let imgEnemy=GetCurrentScriptDirectory~"img\Enemy\zako_blue.png";//画像設定、青
	#include_function".\lib\lib_common.txt"
	#include_function".\lib\lib_anime_Zako.txt"
	@Initialize
	{
		SetLife(8);
                SetInvincibility(20);
                InitializeAction();
                Tmain;
	}
	
	@MainLoop
	{
                if(GetY<cmy-32||GetY>cmY+32||GetX<cmx-32||GetX>cmX+32){VanishEnemy();}
		SetCollisionA(GetX(),GetY(),16);//当たり判定(自弾)登録
		yield;
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
	}

        task Tmain{

		Move;
		let Sangle= GetAngleToPlayer;//弾角度
		alternative(Level)
		case(1){//hard
			loop(5){
				loop(20){yield;}
				PlaySE(arrow01);
				Sangle= GetAngleToPlayer;//弾角度
				loop(18){
					CreateShot01(GetX,GetY,6,Sangle,27,0);
					CreateShot01(GetX,GetY,2,Sangle,27,0);
					Sangle+=360/18;
				}
			}
			Sangle= GetAngleToPlayer;//弾角度
		}
		case(0){//easy
			loop(4){
				PlaySE(arrow01);
				Sangle= GetAngleToPlayer+360/10/2;//弾角度
				loop(10){
					CreateShot01(GetX,GetY,4,Sangle,27,0);
					Sangle+=360/10;
				}
				loop(80){yield;}
			}
			Sangle= GetAngleToPlayer+15;//弾角度
		}
        }

        task Move{
		let angle = GetAngleToPlayer;//敵移動角度
		let speed = GetSpeed;	     //敵速度制御
		let Nspeed= GetSpeed;	     //敵移動速度
		SetAngle(angle);
		SetAction(ACT_MOVE,30);
	      	loop(30){
			Nspeed-=speed/30;
			SetSpeed(Nspeed);
			yield;
		}
	      	loop(90){yield;}
		SetAngle(angle/2);
		SetAction(ACT_MOVE,120);
	      	loop(30){
			Nspeed+=3/30;
			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);
		}
		CreateShotFromScript("TenItem",GetX,GetY,0,0,0,0);

	}
	
	@DrawLoop
	{//描画
		DrawBoss(imgEnemy);
		DrawGraphic(GetX(),GetY());

	}
}