#include_script".\Item01.txt"
#include_script".\Item04.txt"
script_enemy_main
{//自機狙い毛玉
	let imgEnemy=GetCurrentScriptDirectory~"img\Enemy\other.png";//画像設定、毛玉
	#include_function".\lib\lib_common.txt"

	let DrawAngle=0;
	@Initialize
	{
		SetLife(1);
                Tmain;
	}
	
	@MainLoop
	{
                if(GetY<cmy-32||GetY>cmY+32||GetX<cmx-32||GetX>cmX+32){VanishEnemy();}
		SetCollisionA(GetX(),GetY(),16);//当たり判定(自弾)登録
		yield;
	}

        task Tmain{
		Move;
      		loop(10){yield;}
		alternative(Level)
		case(1){//hard
			loop(32){
				let angle=GetAngleToPlayer;
				PlaySE(sha00);
				loop(4){
					let speed=7;
					loop(2){
						CreateShot01(GetX,GetY,speed ,angle,70,0);
						speed-=3;
					}
					angle+=90;
				}
				loop(5){yield;}
			}
		}
		case(0){//easy
			PlaySE(sha00);
			CreateShot01(GetX,GetY,6 ,GetAngleToPlayer,70,10);
			loop(160){yield}
			PlaySE(sha00);
			CreateShot01(GetX,GetY,5 ,GetAngleToPlayer,70,10);
		}

        }

        task Move{
		let angle=GetAngle;
		SetAngle(angle);
		loop(30){yield;}
		loop(120){
			SetAngle(angle);
			angle+=GetArgument;
			yield;
		}
      
        }
 
	@Finalize
	{
		if(BeVanished==true){return;}
		loop(2){
			CreateShotFromScript("I_Item",GetX+rand(-15,15),GetY+rand(-15,15),0,0,0,0);
		}
		CreateShotFromScript("P_Item",GetX,GetY,0,0,0,0);

	}

	@DrawLoop
	{//描画
		SetTexture(imgEnemy);
		SetGraphicRect(96,32,127,63);
		SetGraphicAngle(0,0,DrawAngle);
		DrawGraphic(GetX(),GetY());
		DrawAngle+=4;
	}
}

