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

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

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 PowerBerDisplay//ライフバーの枠の設定
{
		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 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+35,GetClipMaxY-32);
		let Alpha;
		loop(600)
		{

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

			if(RushGauge>0)
			{
				ObjEffect_SetAngle(obj,0,0,0);
				scale=1.0*(absolute(RushGauge))/100/2;
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,Alpha,255,0,0);				}
			}
			else
			{
				scale=1.0*(absolute(RushGauge))/100/2;
				ObjEffect_SetAngle(obj,0,0,180);
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,Alpha,0,0,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,  128, 0);
		ObjEffect_SetVertexUV(obj, 2, 128,  128);
		ObjEffect_SetVertexUV(obj, 3, 0, 128);

		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..6)
	{
		BurstEffectStar(i*60,3,0,1);
		BurstEffectStar(i*60,3,0,-1);
	}
	wait(5);
	ascent(let i in 0..6)
	{
		BurstEffectStar(i*60,2,0,1);
		BurstEffectStar(i*60,2,0,-1);
	}
	wait(5);
	ascent(let i in 0..6)
	{
		BurstEffectStar(i*60,1,0,1);
		BurstEffectStar(i*60,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,  64, 0);
		ObjEffect_SetVertexUV(obj, 2, 64,  64);
		ObjEffect_SetVertexUV(obj, 3, 0, 64);
	/*	
		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  256, 0);
		ObjEffect_SetVertexUV(obj, 2, 256,  256);
		ObjEffect_SetVertexUV(obj, 3, 0, 256);

		ObjEffect_SetScale(obj, Scale,Scale);
*/
		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 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..6)
	{
		BurstEffectStar(i*60,-3,64*3,1);
		BurstEffectStar(i*60,-3,64*3,-1);
	}
	wait(5);
	ascent(let i in 0..6)
	{
		BurstEffectStar(i*60,-2.5,64*2.5,1);
		BurstEffectStar(i*60,-2.5,64*2.5,-1);
	}
	wait(5);
	ascent(let i in 0..6)
	{
		BurstEffectStar(i*60,-2,64*2,1);
		BurstEffectStar(i*60,-2,64*2,-1);
	}
}


task StartStar
{
	OnCansellBomb=1;
	let X=GetPlayerX;
	let Y=GetPlayerY;
	let i=0;
	let r=120;
	let angle=rand(0,360);
	loop(30)
	{
		ascent(let k in 0..7)
		{
			StartStarEffect(X-((X-GetPlayerX)/30)*i,Y-((Y-GetPlayerY)/30)*i,r,angle+360/7*k,9+k);
		}
	yield;
	i+=1;
	if(r>0)
	{
	r-=120/30;
	}
	if(r<=0)
	{
	r-=60/30;
	}
	angle+=4.5;
	}
	wait(90);
	OnCansellBomb=0;
}

task StartStarEffect(X,Y,Radius,Angle,graphic)
{
		let R;let G;let B;
		if(graphic==9){R=255;G=0;B=0;}
		if(graphic==10){R=255;G=100;B=0;}
		if(graphic==11){R=255;G=255;B=0;}
		if(graphic==12){R=0;G=255;B=0;}
		if(graphic==13){R=0;G=255;B=255;}
		if(graphic==14){R=0;G=0;B=255;}
		if(graphic==15){R=160;G=32;B=240;}

		let Scale=0.6;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X+Radius*cos(Angle),Y+Radius*sin(Angle));
		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,  384);
		ObjEffect_SetVertexUV(obj, 1,  128, 384);
		ObjEffect_SetVertexUV(obj, 2, 128,  512);
		ObjEffect_SetVertexUV(obj, 3, 0, 512);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,200,R,G,B);
		}
		if(GetCommonDataDefault("LightMode",0)==0)
		{
		loop(30)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.02;
			yield;
		}
		}
		else
		{
		loop(10)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			Scale-=0.06;
			yield;
		}
		}
		Obj_Delete(obj);
}