
#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 {
	SetX(GetCommonDataDefault("BossX",0));
	SetY(GetCommonDataDefault("BossY",0));
	MagicCircle(false);
       LoadUserShotData(GetCurrentScriptDirectory~".\img\shot_All.txt");
        SetLife(1);
	InitializeAction();
        TMain;
    }

    @MainLoop {
        yield;
    }

    @DrawLoop {
	DrawBoss( imgBoss );
    }

    @Finalize {
    }

    // メインタスク
task TMain 
{
	Particle;
	//Lissajous(0,250,154);
	BossShadowAnimation(imgBoss2,0,0,250,154);
	//SetCommonData("BOSSDEFEAT",true);
	standBy;
}

sub standBy//初期位置へ
{
	wait(45);
	SetAction(ACT_MOVE, 60);
	SetMovePosition02(GetCenterX, GetClipMinY-64, wIni);
	wait(45);
	VanishEnemy;
}

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

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"
}
