#e
#Title[uGNXpV[hv]
#Text[]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uGNXpV[hv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "lib/dot_sakuya.png"; 
    let imgFam  = csd ~ "img\familiar.png";
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 112;
let judg=0;
    @Initialize {

        SetLife(1700);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
        TMain;
    }

    @MainLoop {
	if(!OnBomb)
	{
	SetAlpha(255);
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	if(judg==1)
	{
        SetDamageRate(50, 0);
	}
	}

	if(OnBomb)
	{
		SetAlpha(100);
      		  SetDamageRate(0, 0);
		judg=1;

	}
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
    }

    @Finalize {
        DeleteGraphic(imgBoss);
    }

    // C^XN
task TMain 
{
	yield;
	standBy;
	spell;
	Trate;
	Shot;
}

task Trate
{
	wait(120);
        SetDamageRate(50, 50);
}

sub standBy//ʒu
{
	SetAction(ACT_MOVE, 60);
	let wIni = 60;
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}

sub spell//[V
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(50);
        SetScore(22000000/3);
	SetAction(ACT_SPELL,90);
	wait(90);
}


task Shot
{
	loop
	{
		let d=1;
		let Angle=[];
		ascent(let i in 0..16)
		{
		let j=i*22.5+GetAngleToPlayer;
		Angle=Angle~[j];
		}

		CreateShot01(GetX,GetY,2,Angle[0],RED03,0);
		CreateShot01(GetX,GetY,2,Angle[0]+30,RED03,0);
		CreateShot01(GetX,GetY,2,Angle[0]-30,RED03,0);
		ascent(let i in 0..16)
		{	
		shot(GetX,GetY,2,Angle[i],BLUE32,0);
		}
		wait(60);
		TimeStop(60,1,1,1);
		loop(3)
		{
		ascent(let i in 0..16)
		{
		rs(Angle[i],d,BLUE32);
		}
		wait(10);
		d++;
		}

		wait(180);
		yield;
	}
}

function rs(angle,d,color)
{
shot(GetX+(120+d*25)*cos(angle),GetY+(120+d*25)*sin(angle),2,angle,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle-45),GetY+120*sin(angle)+d*25*sin(angle-45),2,angle-45,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle+45),GetY+120*sin(angle)+d*25*sin(angle+45),2,angle+45,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle-90),GetY+120*sin(angle)+d*25*sin(angle-90),2,angle-90,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle+90),GetY+120*sin(angle)+d*25*sin(angle+90),2,angle+90,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle-135),GetY+120*sin(angle)+d*25*sin(angle-135),2,angle-135,color,0);
shot(GetX+120*cos(angle)+d*25*cos(angle+135),GetY+120*sin(angle)+d*25*sin(angle+135),2,angle+135,color,0);
}


task shot(let x, let y, let speed,let angle, let graphic, let delay)
{
	let count=0;
	let count1=0;
	let count3=0;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, speed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, delay);
	ObjShot_SetBombResist(obj,true);
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_GetX(obj)<GetClipMinX-5 && count==0)//[ł̋
		{
			Obj_Delete(obj);
        	}
		if(Obj_GetX(obj)>GetClipMaxX+5 && count==0)//E[ł̋
		{
			Obj_Delete(obj);
        	}
		if(Obj_GetY(obj)<GetClipMinY-5 && count==0)//E[ł̋
		{
			Obj_Delete(obj);
        	}

		if(Obj_GetX(obj)<GetClipMinX && count==0)//[ł̋
		{
			Obj_SetX(obj, GetClipMinX*2-Obj_GetX(obj));
			Obj_SetAngle(obj,180-angle);
			count=1;
        	}
		if(Obj_GetX(obj)>GetClipMaxX && count==0)//E[ł̋
		{
			Obj_SetX(obj, GetClipMaxX*2-Obj_GetX(obj));
			Obj_SetAngle(obj,180-angle);
			count=1;
        	}
		if(Obj_GetY(obj)<GetClipMinY && count==0)//[ł̋
		{
			Obj_SetY(obj, GetClipMinY*2-Obj_GetY(obj));
			Obj_SetAngle(obj,360-angle);
			count=1;
        	}
		
		if(count3>=180)
		{
		ObjShot_SetBombResist(obj,false);
		}
		count3++;
		yield;
    	}

}
#include_function ".\data.txt"
#include_function ".\lib/lib_anime_Sakuya.txt"
}