#e
#Title[⏻uR[hNX^v]
#Text[B]
#ScriptVersion[2]

script_enemy_main
{
	let count=-60;
	let lv = GetCommonDataDefault("lv",2);
	let bg=0;
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SxW擾
	let name        = "⏻uR[hNX^v";
	#include_function ".\lib\lib_anime_Remilia.txt"
	let imageBoss = ".\script\wx\img\dot_cirno.png";
	if (lv>2) {name = "⏻uR[h_Chv";}
	@Initialize{
		CutIn(KOUMA, name, "", 0, 0, 0, 0);
		LoadGraphic(imageBoss);
		InitializeAction();
		SetLife(5000);
		SetTimer(50);
		SetDamageRate(100,100);
       		SetScore(5000000);
		SetMovePosition02(cx,cy,60);
		SetAction(ACT_SPELL,180);
		LoadGraphic("script\wx\img\bg.png");
	}
	
	@MainLoop
	{
		if(0 < GetHitCount)
		{
			PlaySE(".\script\wx\sound\enemy_damage.wav");
		}
		if (GetTimer>0 && GetTimer<12 && count%60==0)
		{
			PlaySE(".\script\wx\sound\clock.wav");
		}
		count++;
		
		if (count>0) {
		if (count==60)
		{
			PlaySE(".\script\wx\sound\enemy_powereffect.wav");
			Concentration02(60);
		}
		if (count==180)
		{
			SetAction(ACT_SHOT_A,6000);
			StopSE(".\script\wx\sound\enemy_powereffect.wav");
			PlaySE(".\script\wx\sound\shot2.wav");
			let angle=getAngleToPlayer(GetX,GetY);
			if (lv<3)
			{
				loop(6)
				{
					IceShot(angle);
					angle+=60;
				}
			} else if (lv==3) {
				loop(8)
				{
					IceShot(angle);
					angle+=45;
				}
			} else {
				loop(12)
				{
					IceShot(angle);
					angle+=30;
				}
			}
		}
		if (count==2100)
		{
			PlaySE(".\script\wx\sound\enemy_powereffect.wav");
			Concentration02(60);
		}
		if (count==2220)
		{
			StopSE(".\script\wx\sound\enemy_powereffect.wav");
			PlaySE(".\script\wx\sound\shot2.wav");
			let angle=getAngleToPlayer(GetX,GetY);
			if (lv<3)
			{
				loop(6)
				{
					IceShot(angle);
					angle+=60;
				}
			} else if (lv==3) {
				loop(8)
				{
					IceShot(angle);
					angle+=45;
				}
			} else {
				loop(12)
				{
					IceShot(angle);
					angle+=30;
				}
			}
		}

		SetCollisionA(GetX(),GetY(),24);//蔻(e)o^
		SetCollisionB(GetX(),GetY(),12);//蔻(̓)o^
		}
		yield;
	}
	@DrawLoop{DrawBoss( imageBoss);}
	@BackGround{SetTexture("script\wx\img\bg.png");SetAlpha(64);SetGraphicRect(bg,bg,cx*2+bg,cy*2+bg);bg++;DrawGraphic(cx,cy);SetGraphicRect(-bg,-bg,cx*2-bg,cy*2-bg);DrawGraphic(cx,cy);SetGraphicRect(bg,-bg,cx*2+bg,cy*2-bg);DrawGraphic(cx,cy);SetGraphicRect(-bg,bg,cx*2-bg,cy*2+bg);DrawGraphic(cx,cy);}
	task IceShot(let angle)
	{
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetX,GetY);
		Obj_SetAngle(obj,angle);
		Obj_SetSpeed(obj,1);
		ObjShot_SetGraphic(obj,BLUE23);
		ObjShot_SetDelay(obj,60);
		let count=0;
		while(!Obj_BeDeleted(obj))
		{
			count++;
			if ((count%90==45 && lv>2) || (count%90==0 && lv>1) || (count%180==0 && lv==1))
			{	
				PlaySE(".\script\wx\sound\shot2.wav");
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),1,angle+45,-0.01,-2,BLUE23,60);
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),1,angle-45,-0.01,-2,BLUE23,60);
			}
			if ((count%60==30 && lv>2) || (count%60==0 && lv>1) || (count%120==0 && lv==1))
			{
				PlaySE(".\script\wx\sound\shot2.wav");
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),0.5,angle+45,-0.01,-1,BLUE23,60);
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),0.5,angle-45,-0.01,-1,BLUE23,60);
			}
			if ((count%150==75 && lv>2) || (count%150==0 && lv>1) || (count%300==0 && lv==1))
			{
				PlaySE(".\script\wx\sound\shot2.wav");
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),1.5,angle+45,-0.01,-3,BLUE23,60);
				CreateShot02(Obj_GetX(obj),Obj_GetY(obj),1.5,angle-45,-0.01,-3,BLUE23,60);
			}
			yield;
		}
		IceShot(-angle);
		
	}
	function getAngleToPlayer(x, y)
	{
  		return atan2(GetPlayerY - y, GetPlayerX - x);
 	}	
	@Finalize
	{//ǂ݂񂾃t@C폜
		loop(16){CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-50,50));}
	}
	
}