
#Title[逃亡]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.png";
    let imgBoss2 =csd ~ "..\lib/dot_daiyousei2.png";
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=30;
    @Initialize {
	//SetTimer(-1);
	SetX(GetCommonDataDefault("BossX",0));
	SetY(GetCommonDataDefault("BossY",0));
       LoadUserShotData(GetCurrentScriptDirectory~".\img\shot_All.txt");
        SetLife(1);
	InitializeAction();
        TMain;
	if(GetCommonData("BURSTLEVEL")==3)
	{
		SetCommonDataEx(NsScore,NsAchievement[78],1);
	}
    }

task Defeat
{

}
    @MainLoop {
        yield;
    }

    @DrawLoop {
	DrawBoss( imgBoss );
    }

    @Finalize {
	SetCommonData("BossLastAttack",false);
    }

    // メインタスク
task TMain 
{
	yield;
	Particle;
	SetCommonData("BurstStop",true);
	BossShadowAnimation(imgBoss2,0,0,250,154);
	wait(185);
	SetCommonData("BOSSDEFEAT",true);
	VanishEnemy;
}

task Particle
{
loop
{
ParticleEffect;
wait(10);
}
}

task ParticleEffect
{
		let obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, csd~"..\img\ParticleEffect.png");
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -8, -8);
		ObjEffect_SetVertexXY(obj, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj, 2, 8, 8);
		ObjEffect_SetVertexXY(obj, 3,  -8,  8);

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  16, 0);
		ObjEffect_SetVertexUV(obj, 2, 16,  16);
		ObjEffect_SetVertexUV(obj, 3, 0, 16);
		let Alpha=100;
		let StandardAlpha=Alpha;
		let R;let G;let B;
		R=0;G=255;B=0;
		ObjEffect_SetLayer(obj,1);
		Obj_SetPosition(obj,GetX+rand(-20,20),GetY+rand(-20,20));
		let speed=rand(0.5,1.0);
		let angle=rand(88,92);
		let Scale=0.5;
		let StandardScale=Scale;
		if(GetCommonDataDefault("LightMode_BossBlur",0)==1){Obj_Delete(obj);return;}
		loop(30)
		{
			Alpha-=StandardAlpha/30;
			Scale-=StandardScale/30;
			Obj_SetPosition(obj,Obj_GetX(obj)+speed*cos(angle),Obj_GetY(obj)+speed*sin(angle));
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			yield;
		}
		Obj_Delete(obj);
}
#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Daiyousei.txt"
}
