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(3000);
		SetTimer(40);
		SetDamageRate(100,100);
		SetMovePosition02(cx,100,60);
	}
	
	@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%30==0 && count%300>0 && count%300<120 && lv>1) || (count%30==0 && count%300>119 && count%300<240 && lv>3) || (count%60==0 && count%600>0 && count%600<240 && lv==1))
		{
			SetAction(ACT_SHOT_B,60);
			PlaySE(".\script\『冷』\sound\shot2.wav");
			let angle=getAngleToPlayer(GetX,GetY)-20;
			loop(3)
			{
				IceShot(angle);
				angle+=20;
			}
		}
		if ((count%5==0 && count%300>150 && count%300<240 && lv>1) || (count%5==0 && count%300>60 && count%300<151 && lv>3) || (count%10==0 && count%600>300 && count%600<480 && lv==1))
		{
			PlaySE(".\script\『冷』\sound\shot1.wav");
			if (lv<3) {loop(2){CreateShot01(GetX,GetY,rand(1,2),rand(0,360),BLUE01,30);}}
			else {loop(2){CreateShot01(GetX,GetY,rand(3,4),rand(0,360),BLUE01,30);}}
			SetAction(ACT_SHOT_A,10);
		}
		if (count%600==0)
		{
			SetMovePosition02(rand(50,cx*2-50),rand(50,cy-50),60);
			SetAction(ACT_MOVE,60);
		}

		SetCollisionA(GetX(),GetY(),24);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),12);//当たり判定(体当たり)登録
		}
		yield;
	}
	@DrawLoop{DrawBoss( imageBoss);}
	task IceShot(let angle)
	{
		let obj=Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,GetX+cos(angle)*30,GetY+sin(angle)*30);
		ObjLaser_SetLength(obj,0);
		ObjLaser_SetWidth(obj,10);
		ObjLaser_SetSource(obj, false);
		Obj_SetAngle(obj,angle);
		Obj_SetSpeed(obj,2);
		ObjShot_SetGraphic(obj,AQUA01);
		let length=0;
		while(!Obj_BeDeleted(obj))
		{
			ObjLaser_SetLength(obj,length);
			if (length<300) {length+=2;} else {Obj_SetPosition(obj,Obj_GetX(obj)+cos(Obj_GetAngle(obj))*Obj_GetSpeed(obj),Obj_GetY(obj)+sin(Obj_GetAngle(obj))*Obj_GetSpeed(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));}
	}
	
}