#e
#Title[╄utWC^[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        = "╄utWC^[v";
	let n=0;
	#include_function ".\lib\lib_anime_Remilia.txt"
	let imageBoss = ".\script\wx\img\dot_cirno.png";
	if (lv>2) {name = "╄uR[ht[U[v";}
	@Initialize{
		CutIn(KOUMA, name, "", 0, 0, 0, 0);
		LoadGraphic(imageBoss);
		InitializeAction();
		SetLife(8000);
		SetTimer(70);
		SetDamageRate(100,100);
       		SetScore(5000000);
		SetMovePosition02(cx,100,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%600==180)
		{
			PlaySE(".\script\wx\sound\enemy_powereffect.wav");
			Concentration02(90);
		}
		
		if (count%600==300)
		{
			StopSE(".\script\wx\sound\enemy_powereffect.wav");
			PlaySE(".\script\wx\sound\enemy_vanish.wav");
			let angle=getAngleToPlayer(GetX,GetY);
			let x=0;
			let y=0;
			loop(2)
			{
				y=0;
				loop(9)
				{
					IceShot(x,y);
					y+=cy/4.5;
				}
				x=cx*2;
			}
			y=0;
			loop(2)
			{
				x=0;
				loop(9)
				{
					IceShot(x,y);
					x+=cy/4.5;
				}
				y=cy*2;
			}
			x=0;
			loop(n)
			{
				x+=cx*2/(n+1);
				y=0;
				loop(9)
				{
					IceShot(x,y);
					y+=cy/4.5;
				}
			}
			y=0;
			loop(n)
			{
				x=0;
				y+=cy*2/(n+1);
				loop(9)
				{
					IceShot(x,y);
					x+=cx/4.5;
				}
			}
			n++;
		}
		if (count%600==0)
		{
			SetMovePosition02(rand(50,cx*2-50),rand(50,cy-50),60);
			SetAction(ACT_MOVE,60);
		}

		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 x,let y)
	{
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,x,y);
		ObjShot_SetBombResist(obj,true);
		ObjShot_SetGraphic(obj,WHITE03);
		ObjShot_SetDelay(obj,60);
		loop(600)
		{
			if ((count%180==90 && lv==2) || (count%360==90 && lv==1) || (count%180==0 && lv>2))
			{
				PlaySE(".\script\wx\sound\shot1.wav");
				if (lv<4) {CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,count/2+45,WHITE04,60);} else {CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,count/2+45+rand(-5,5),WHITE04,60);}
			}
			if (Obj_BeDeleted(obj)) {break;}
			yield;
		}
		Obj_Delete(obj);
	}
	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));}
	}
	
}