script_enemy_main
{
	let count=-60;
	let lv = GetCommonDataDefault("lv",2);
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心x座標を取得
	#include_function ".\lib\lib_anime_Remilia.txt"
	let imageBoss = ".\script\『冷』\img\dot_cirno.png";
	@Initialize{
		LoadGraphic(imageBoss);
		InitializeAction();
		SetLife(2000);
		SetTimer(30);
		SetDamageRate(100,100);
		SetMovePosition02(cx,100,60);
		SetAction(ACT_SPELL,180);
	}
	
	@MainLoop
	{
		if(0 < GetHitCount)
		{
			PlaySE(".\script\『冷』\sound\enemy_damage.wav");
		}
		if (GetTimer>0 && GetTimer<12 && count%60==0)
		{
			PlaySE(".\script\『冷』\sound\clock.wav");
		}
		count++;
		
		if (count>0) {
		if ((count%90==45 && lv>3) || (count%90==0 && lv>1) || (count%180==0 && lv==1))
		{
			let angle=0;
			SetAction(ACT_SHOT_B,30);
			PlaySE(".\script\『冷』\sound\shot2.wav");
			loop(18)
			{
				IceShot(angle);
				angle+=20;
			}
		}
		
		if ((count%5==0 && count%90>30 && count%90<60 && lv>1) || (count%10==0 && count%180>60 && count%180<120 && lv==1) || (count%5==0 && count%90>0 && count%90<31 && lv>3))
		{
			PlaySE(".\script\『冷』\sound\shot1.wav");
			SetAction(ACT_SHOT_A,5);
			let angle=getAngleToPlayer(GetX,GetY)-40;
			loop(5)
			{
				if (lv<3) {CreateShot01(GetX+cos(angle)*50,GetY+sin(angle)*50,3,angle,AQUA02,60);}
				else {CreateShot01(GetX+cos(angle)*50,GetY+sin(angle)*50,6,angle,AQUA02,60);}
				angle+=20;
			}
		}
		if (count%300==0)
		{
			SetMovePosition02(rand(50,cx*2-50),rand(50,cy-50),30);
			SetAction(ACT_MOVE,30);
		}

		SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),12);//当たり判定(体当たり)登録
		}
		yield;
	}
	@DrawLoop{DrawBoss( imageBoss);}
	task IceShot(let angle)
	{
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetX+cos(angle)*30,GetY+sin(angle)*30);
		Obj_SetAngle(obj,angle);
		if (lv<3) {Obj_SetSpeed(obj,2);} else {Obj_SetSpeed(obj,3);}
		ObjShot_SetDelay(obj,30);
		ObjShot_SetGraphic(obj,BLUE23);
		loop(90)
		{
			if (Obj_BeDeleted(obj)) {break;}
			yield;
		}
		Obj_SetSpeed(obj,0);
		Obj_SetAngle(obj,getAngleToPlayer(Obj_GetX(obj),Obj_GetY(obj)));
		loop(30)
		{
			if (Obj_BeDeleted(obj)) {break;}
			yield;
		}
		if (lv<3) {Obj_SetSpeed(obj,3);} else {Obj_SetSpeed(obj,4);}
		while(!Obj_BeDeleted(obj))
		{
			yield;
		}
		
	}
	function getAngleToPlayer(x, y)
	{
  		return atan2(GetPlayerY - y, GetPlayerX - x);
 	}	
	@Finalize
	{//読みこんだファイルを削除
		loop(16){CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));}
	}
	
}