#e
#Title[uT[N[hv]
#Text[]
#Image[.]
#BackGround[User]
#ScriptVersion[2]
script_enemy_main {
    let name    = "uT[N[hv";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "lib/dot_sakuya.png"; 
    let SE=[csd~"SE\eco02_b.wav",
	csd~"SE\buble03.wav"];
SetRateScoreSystemEnable(false);
    // ʒu
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
let judg=0;
    @Initialize {

        SetLife(1700);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        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;
	TMove;
	Shot;
}

task Trate
{
	wait(240);
        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 TMove// g
{
	let angle = 0;
	loop
	{
		SetY(yIni + 4 * sin(angle));
		yield;
		angle += 3;
	}
}


task Shot
{
	loop
	{
		let w=0;
		loop(20)
		{
			shot(GetX,GetY,rand(3,4),80-w+rand(-3,3),RED32,0);
			wait(4);
			w+=5;
		}
		wait(5);
		let w=0;
		loop(20)
		{
			shot(GetX,GetY,rand(3,4),110+w+rand(-3,3),BLUE32,0);
			wait(4);
			w+=5;
		}
		wait(5);
	}
}

task shot(let x, let y, let speed,let angle, let graphic, let delay)
{
	let count=0;
	let count1=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);
	while(!Obj_BeDeleted(obj))
	{

		if(Obj_GetX(obj)<GetClipMinX && count<=2)//[ł̋
		{
			Obj_SetX(obj,GetClipMaxX);
			count+=1;
        		}
		if(Obj_GetX(obj)>GetClipMaxX && count<=2)//E[ł̋
		{
			Obj_SetX(obj,GetClipMinX);
			count+=1;
        		}
		if(Obj_GetY(obj)>GetClipMaxY && count1==0)//[ł̋
		{
			Obj_SetY(obj,GetClipMinY);
			count1=1;
        		}
		yield;
    	}

}

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