task BurstGaugeDisplay//バーストゲージを表示
{
BerD;
loop
{
//PowerBerDisplay;
//PowerDisplayback;
wait(600);
}
}

task BerD
{
loop
{
while(BurstMode==0){yield;}
PowerDisplay;
while(BurstMode==1){yield;}
}
}

task PowerBerDisplay//ライフバーの枠の設定
{
	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-32);

		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 PowerDisplay//ライフバーのバー部分の設定
{
		let randvertex=0;
		let VertexNum=48;
		let Radius=[40,46];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-1)*i), Radius[i%2]*sin(360/(VertexNum-1)*i));
		}
		ascent(let i in 0..VertexNum)
		{	
			ObjEffect_SetVertexUV(obj, i,  512/(VertexNum)*i,  27+6*(i%2));
		}

		ObjEffect_SetLayer(obj,3);

		ObjEffect_SetAngle(obj,0,0,-90);
		let Alpha=100;

		while(BurstMode==1)
		{

		if(Power<=1000)
		{
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexColor(obj, i,Alpha,ColorRed,ColorGreen,ColorBlue);
			}
			ascent(let i in 0..VertexNum-VertexNum*(Power/1000))
			{			
				ObjEffect_SetVertexColor(obj, i,0,255,255,255);
			}
		}
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		yield;
		}
		Obj_Delete(obj);
}

task PowerDisplayback//ライフバーのバー部分の設定
{
		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-32);
		let Alpha;
		loop(600)
		{

			if(GetPlayerY>GetClipMaxY-60)
			{
				Alpha=255+((GetClipMaxY-60)-GetPlayerY)*4;
			}
			else
			{
				Alpha=255;
			}

			if(Power+ReChargePower==1000 || BurstMode)
			{
				scale=1.0*(Power+ReChargePower)/1000;
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,Alpha,ColorRed,ColorGreen,ColorBlue);
				}
			}
			else
			{
				scale=1.0*(Power+ReChargePower)/1000;
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,Alpha,255,255,255);
				}
			}
			ObjEffect_SetScale(obj, scale,0.6);
			yield;
		}
		Obj_Delete(obj);
}

task PowerChargeEffect
{
		let Scale=2;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -80, -80);
		ObjEffect_SetVertexXY(obj, 1,  80, -80);
		ObjEffect_SetVertexXY(obj, 2,  80,  80);
		ObjEffect_SetVertexXY(obj, 3, -80,  80);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  160, 0);
		ObjEffect_SetVertexUV(obj, 2, 160,  160);
		ObjEffect_SetVertexUV(obj, 3, 0, 160);

		let Alpha=150;
		while(Alpha>0)
		{
			Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
			ObjEffect_SetScale(obj, Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,ColorRed,ColorGreen,ColorBlue);
			}
			Alpha-=2.5;
			Scale-=0.07;
			yield;
		}
		Obj_Delete(obj);
}

task BurstStartEffect
{
	BurstEffect(1);
	BurstEffect(-1);
	wait(5);
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,3,0,1);
		BurstEffectStar(i*45,3,0,-1);
	}
	wait(5);
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,2,0,1);
		BurstEffectStar(i*45,2,0,-1);
	}
	wait(5);
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,1,0,1);
		BurstEffectStar(i*45,1,0,-1);
	}
}

task BurstEffect(dir)
{
		let Scale=0;
		let Xangle=90;
		let Yangle=90;
		let Zangle=0;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgKekkai);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -128, -128);
		ObjEffect_SetVertexXY(obj, 1,  128, -128);
		ObjEffect_SetVertexXY(obj, 2,  128,  128);
		ObjEffect_SetVertexXY(obj, 3, -128,  128);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);

		let Alpha=150;
		while(Alpha>0)
		{
			Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
			ObjEffect_SetScale(obj, Scale,Scale);
			ObjEffect_SetAngle(obj, Xangle,Yangle,Zangle);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,255,255);
			}
			Alpha-=2.5;
			Scale+=0.035;
			Zangle+=2.25*dir;
			Xangle+=2.25*dir;
			Yangle+=2.25;
			yield;
		}
		Obj_Delete(obj);
}

task BurstEffectStar(angle,speed,rudius,dir)
{
		let Scale=0;
		let Xangle=90;
		let Yangle=90;
		let Zangle=0;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgMarisaShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -64, -64);
		ObjEffect_SetVertexXY(obj, 1,  64, -64);
		ObjEffect_SetVertexXY(obj, 2,  64,  64);
		ObjEffect_SetVertexXY(obj, 3, -64,  64);
		
		ObjEffect_SetVertexUV(obj, 0,  0,  256);
		ObjEffect_SetVertexUV(obj, 1,  128, 256);
		ObjEffect_SetVertexUV(obj, 2, 128,  378);
		ObjEffect_SetVertexUV(obj, 3, 0, 378);

		let Alpha=255;

		while(Alpha>0)
		{
			Obj_SetPosition(obj,GetPlayerX+rudius*cos(angle),GetPlayerY+rudius*sin(angle));
			ObjEffect_SetScale(obj, Scale,Scale);
			ascent(let i in 0..4)
			{
				if(Power<1000)
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,127,127,127);
				}
				if(Power>=1000 && Power<2000 || BurstLevel==1)
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,127,127,255);
				}
				if(Power>=2000 && Power<3000 || BurstLevel==2)
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,255,127,127);
				}
				if(Power>=3000 || BurstLevel==3)
				{
				ObjEffect_SetVertexColor(obj,i,Alpha,ColorRed,ColorGreen,ColorBlue);
				}
			}
			Alpha-=4;
			Scale+=0.01;
			rudius+=speed;
			angle+=3*dir;
			yield;
		}
		Obj_Delete(obj);
}

task BurstEndEffect
{
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,-3,64*3,1);
		BurstEffectStar(i*45,-3,64*3,-1);
	}
	wait(5);
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,-2.5,64*2.5,1);
		BurstEffectStar(i*45,-2.5,64*2.5,-1);
	}
	wait(5);
	ascent(let i in 0..8)
	{
		BurstEffectStar(i*45,-2,64*2,1);
		BurstEffectStar(i*45,-2,64*2,-1);
	}
}