task BombExtend
{

let BombExtendNum=0;
let BombExtendCounter=0;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}
loop
{
BombBerDisplay;
BombDisplay;
wait(600);
}


task BombBerDisplay//ライフバーの枠の設定
{
	let BossLifeMax=GetEnemyLife;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -71, -5);
		ObjEffect_SetVertexXY(obj, 1, 0,  -5);
		ObjEffect_SetVertexXY(obj, 2, 0, 5);
		ObjEffect_SetVertexXY(obj, 3,  -71,  5);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  11);
		ObjEffect_SetVertexUV(obj, 1,  148, 11);
		ObjEffect_SetVertexUV(obj, 2, 148,  21);
		ObjEffect_SetVertexUV(obj, 3, 6, 21);
		ObjEffect_SetLayer(obj,3);
		ObjEffect_SetScale(obj, 1,0.6);
		Obj_SetPosition(obj,GetClipMinX+71,GetClipMaxY-16);

		loop(600)
		{
			if(GetPlayerY>GetClipMaxY-60)
			{
				ascent(i in 0..4)
				{
					ObjEffect_SetVertexColor(obj, i, 255+((GetClipMaxY-60)-GetPlayerY)*4, 255, 255, 255);
				}
			}
			else
			{
				ascent(i in 0..4)
				{
					ObjEffect_SetVertexColor(obj, i, 255+((GetClipMaxY-60)-GetPlayerY)*4, 255, 255, 255);
				}
			}
			yield
		}
		Obj_Delete(obj);
}

task BombDisplay//ライフバーのバー部分の設定
{
		let scale=2.5;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -3);
		ObjEffect_SetVertexXY(obj, 1, 71,  -3);
		ObjEffect_SetVertexXY(obj, 2, 71, 3);
		ObjEffect_SetVertexXY(obj, 3,  0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  148, 27);
		ObjEffect_SetVertexUV(obj, 2, 148,  33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);
		ObjEffect_SetLayer(obj,3);

		ascent(let i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,150,255,255,255);
		}

		Obj_SetPosition(obj,GetClipMinX-0,GetClipMaxY-16);
		let Alpha;
		loop(600)
		{
			BombExtendCounter=MagicCounter-(10000*BombExtendNum+5000*0.5*BombExtendNum*(BombExtendNum-1));
			if(GetPlayerY>GetClipMaxY-60)
			{
				Alpha=255+((GetClipMaxY-60)-GetPlayerY)*4;
			}
			else
			{
				Alpha=255;
			}

			scale=1.0*BombExtendCounter/(10000+5000*BombExtendNum);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,255,127);
			}
			if(BombExtendCounter>=(10000+5000*BombExtendNum))
			{
				BombExtendCounter-=(10000+5000*BombExtendNum);
				BombExtendNum+=1;
				AddBomb(1);
			}
			ObjEffect_SetScale(obj, scale,0.6);
			yield;
		}
		Obj_Delete(obj);
}


}