task BombExtend
{
let BombExtendNum=0;
let BombExtendCounter=0;
let RankNum=0;
let RankCounter=0;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}
BombDisplay;
let RX=35;
let RY=75;
loop
{
RankBerDisplay(RX+71,RY);
RankDisplay(RX,RY);
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="Extream")
{
RushBerDisplay(RX+71,RY+15);
RushDisplay(RX,RY+15);
}
if(IsBossExisting)
{
	if(RY<GetClipMinY+80)
	{
	RY+=0.5;
	}
}
else
{
	if(RY>GetClipMinY+60)
	{
	RY-=0.5;
	}
}
yield;
}

task BombDisplay//ライフバーのバー部分の設定
{
	let Necessary=0;
	alternative(GetCommonDataDefault("AutoBombMode",0))
	case(0){Necessary=5000;}
	case(0.5){Necessary=10000;}
	case(1){Necessary=15000;}
		loop
		{
			BombExtendCounter=MagicFragment-(Necessary*BombExtendNum);
			if(BombExtendCounter>=Necessary)
			{
				BombExtendCounter-=Necessary;
				BombExtendNum+=1;
				BombExtendTask;
			}
			yield;
		}
}

task BombExtendTask
{
	if((OnMissed))
	{
		while(OnMissed){yield;}
		wait(15);
	}
		
	PlaySE(SE[4]);
	AddBomb(1);
}

task RankBerDisplay(x,y)//ライフバーの枠の設定
{
	//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,x,y);

		let Alpha=50;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
			ascent(i in 0..4)
			{
				ObjEffect_SetVertexColor(obj, i, Alpha, 255, 255, 255);
			}

			yield;
		Obj_Delete(obj);
}

task RankDisplay(x,y)//ライフバーのバー部分の設定
{
		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,x,y);
		let Alpha=50;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
			RankCounter=BurstRank%1000;
			if(BurstRank>=10000){RankCounter=999;}

			scale=RankCounter/1000;
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255*(BurstRank/10000),0,255-255*(BurstRank/10000));
			}
			ObjEffect_SetScale(obj, scale,0.6);
			yield;
		Obj_Delete(obj);
}


task RushBerDisplay(x,y)//ライフバーの枠の設定
{
	//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,x,y);

		let Alpha=50;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
			ascent(i in 0..4)
			{
				ObjEffect_SetVertexColor(obj, i, Alpha, 255, 255, 255);
			}

			yield;
		Obj_Delete(obj);
}

task RushDisplay(x,y)//ライフバーのバー部分の設定
{x+=35;
		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,x,y);
		let Alpha=50;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}

			scale=RushGauge/1000;
			ascent(let i in 0..4)
			{
				if(RushGauge>=0)
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,0,0);
				}
				else
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,0,255,0);
				}
			}
			ObjEffect_SetScale(obj, scale/2,0.6);
			yield;
		Obj_Delete(obj);
}

}