//フランエンド
#include"script/default_system/Default_ShotConst.txt"
#include"script/default_system/Default_Effect.txt"

#include"./../img/boss/lib_anime_Flandre.txt"
#include"./../lib/BossCommon/BossCommon.txt"

@Initialize
{
	BossInit(ObjMove_GetX(GetEnemyBossObjectID[0]),ObjMove_GetY(GetEnemyBossObjectID[0]));
}

@MainLoop
{
	yield;
}

@Event
{

	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(1);//ライフを1500に設定
	}
}

//----------------------------------------------------
//敵動作
//----------------------------------------------------
task BossWork
{
	TExplosion;
//	wait(95);
	SetCommonData("BossDefeat",true);
	ObjEnemy_AddLife(objEnemy,-1);
}

task TExplosion
{
	loop(10)
	{
		Particle2(ObjRender_GetX(objEnemy),ObjRender_GetY(objEnemy),rand(0,360),rand(2.0,3));
		wait(3);
	}
		task Particle2(x,y,angle,Scale)
		{
			let imgBer = GetCurrentScriptDirectory() ~ "../../../img/effect/effects.png";
			let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
			ObjPrim_SetTexture(obj, imgBer);
			ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
			ObjPrim_SetVertexCount(obj, 4);
			ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
			Obj_SetRenderPriorityI(obj,30);

			ObjPrim_SetVertexPosition(obj, 0, 0, -17, -0);
			ObjPrim_SetVertexPosition(obj, 1, 92, -17, -0);
			ObjPrim_SetVertexPosition(obj, 2, 92, 17, 0);
			ObjPrim_SetVertexPosition(obj, 3, 0, 17, 0);

			ObjPrim_SetVertexUVT(obj, 0, 1,3);
			ObjPrim_SetVertexUVT(obj, 1, 93, 3);
			ObjPrim_SetVertexUVT(obj, 2, 93, 38);
			ObjPrim_SetVertexUVT(obj, 3, 1, 38);

			ObjRender_SetPosition(obj,x,y,0);

			let BScale=Scale;
			Scale=0;
			ObjRender_SetScaleXYZ(obj,Scale,Scale,Scale);
			let speed=rand(0.0,0);
			let Xangle=rand(0,360);
			let Yangle=rand(0,360);
			let Zangle=angle;
			ObjRender_SetAngleXYZ(obj,0,0,Zangle);
			let Alpha=150;
			let XPlus=rand(-2,2);
			let YPlus=rand(-2,2);
			let ZPlus=rand(-2,2);
			loop(5)
			{
				Scale+=BScale/5;
				ObjRender_SetScaleXYZ(obj,Scale,BScale/3,Scale);
				ObjRender_SetColor(obj,Alpha,Alpha,Alpha);
				ObjRender_SetAngleXYZ(obj,Xangle,Yangle,Zangle);
				Xangle+=XPlus;
				Yangle+=YPlus;
				Zangle+=ZPlus;
				yield;
			}
			loop(30)
			{
				ObjRender_SetAngleXYZ(obj,Xangle,Yangle,Zangle);
				Xangle+=XPlus;
				Yangle+=YPlus;
				Zangle+=ZPlus;
				yield;
			}
			loop(30)
			{
				ObjRender_SetScaleXYZ(obj,Scale,Scale/3,Scale);
			//	Scale-=BScale/60;
				ObjRender_SetColor(obj,Alpha,Alpha,Alpha);
				Alpha-=150/30;
				ObjRender_SetAngleXYZ(obj,Xangle,Yangle,Zangle);
				Xangle+=XPlus;
				Yangle+=YPlus;
				Zangle+=ZPlus;
				yield;
			}
			Obj_Delete(obj);
		}
}
