//�X�y���ƃ_�~�[�X�y��
task TSpell
{//�d��u��F�̃A�i�U�[�f�B�����W�����v 
	OnSpell=true;
	DimensionFlag=true;
	SetPlayerSpeed(0.0,0.0);
	SetPlayerInvincibilityFrame_Special(120);//���G���Ԃ�ݒ�
	let objManage = GetSpellManageObject();
	Obj_Delete(objManage);

	PlayVol(SE_SPELL1, 56);
	//PlaySE(SE_SPELL2);

	OperationEffect;
	DimensionErase;
	AnotherDimension;
	loop(60){yield;}
	SetPlayerSpeed(4.5,2.0);
	loop(600){yield;if(!DimensionFlag){break;}}
	yield;
	if(!DimensionFlag){SetPlayerSpeed(0.0,0.0);}
	loop(59){yield;}
	SetPlayerSpeed(4.5,2.0);
	OnSpell=false;
	if(DimensionFlag){
		SetPlayerInvincibilityFrame_Special(180);
		DimensionErase;
	}
	DimensionFlag=false;

	task DimensionErase
	{
		ascent(i in 0..45)
		{
			DeleteShotInCircle(TYPE_SHOT,TYPE_ITEM,GetPlayerX,GetPlayerY,i*4+3);
			yield;
		}
	}
	
	task AnotherDimension
	{
		loop(30){yield;}
		DimensionEffect;


		task DimensionEffect
		{
/*			let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
			ObjPrim_SetTexture(obj,IMG_SHOCK);
			ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
			ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
			ObjPrim_SetVertexCount(obj, 4);
			Obj_SetRenderPriorityI(obj,45);
			ObjRender_SetAngleZ(obj,0);

			ObjPrim_SetDestCenter(obj,0,0,512,512);

			ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);

			let Alpha=0;
			let Scale=0.5;
			let R=200;
			let G=200;
			let B=255;
			ObjRender_SetColor(obj,R*Alpha,G*Alpha,B*Alpha);
			ObjRender_SetScaleXYZ(obj,Scale,Scale,Scale);
			loop(690)
			{
				if(!DimensionFlag){break;}
				ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);
				ObjRender_SetColor(obj,R*Alpha,G*Alpha,B*Alpha);
				ObjRender_SetScaleXYZ(obj,Scale,Scale,Scale);
				if(Alpha<0.25){Alpha+=0.25/30;}
				Scale-=0.5/690;
				yield;
			}*/
			let imgGauge = current ~ "./../../Common/img/pl_shot.png";
			let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
			let g_way = 32;
//			let R = 255;
//			let G = 255;
//			let B = 255;
			ObjPrim_SetTexture(obj, imgGauge);
			Obj_SetRenderPriority(obj, 0.30);
			ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
			ObjPrim_SetVertexCount(obj, g_way+2);
			ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
			ObjPrim_SetVertexUVT(obj, 0, 112, 16);
			ascent(i in 0 .. g_way+1){
				ObjPrim_SetVertexUVT(obj, i+1, 112+16*cos(360*i/g_way), 16+16*sin(360*i/g_way));
			}
			let time = 690;
			descent(j in 1 .. time+1){
				if(!DimensionFlag){break;}
				ObjPrim_SetVertexPosition(obj, 0, 0, 0, 0);
//				ObjPrim_SetVertexColor(obj, 0, R, G, B);
				ascent(i in 0 .. g_way+1){
					ObjPrim_SetVertexPosition(obj, i+1, -64*sin(360*j*i/g_way/time), -64*cos(360*j*i/g_way/time), 0);
//					ObjPrim_SetVertexColor(obj, i+1,  R, G, B);
				}
				ObjRender_SetX(obj, GetPlayerX());
				ObjRender_SetY(obj, GetPlayerY());
				yield;
			}
			if(!DimensionFlag)
			{
				ShockWave;
			}
			else
			{
				PlaySE(SE_BONUS);
			}
			Obj_Delete(obj);
		}

		task ShockWave
		{
			OperationEffect;
			let Scale=0;
			let ScalePlus=0;
			let ScalePlusSpeed=0.0125/8*1.33;
		
			loop(46)
			{
				ScalePlus+=ScalePlusSpeed;
				Scale+=ScalePlus;
				DeleteShotInCircle(TYPE_SHOT,TYPE_ITEM,GetPlayerX,GetPlayerY,Scale*256);
				yield;
			}
		}
	}


}

task OperationEffect
{
	ReverseEffect(GetPlayerX,GetPlayerY);
	task ReverseEffect(x,y)
	{
		let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
		ObjPrim_SetTexture(obj,IMG_SHOCK);
		ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjRender_SetBlendType(obj, BLEND_SUBTRACT);
		ObjPrim_SetVertexCount(obj, 4);
		Obj_SetRenderPriorityI(obj,79);
		ObjRender_SetAngleZ(obj,0);

		ObjPrim_SetDestCenter(obj,0,0,512,512);

		ObjRender_SetPosition(obj,x,y,0);

		let Alpha=1.0;
		let Scale=0;
		let ScalePlus=0;
		let ScalePlusSpeed=0.0125/8*1.33;
		let R=255-112;
		let G=255-75;
		let B=255-52;
		ObjRender_SetColor(obj,R*Alpha,G*Alpha,B*Alpha);
		loop(46)
		{
			ScalePlus+=ScalePlusSpeed;
			Scale+=ScalePlus;
			ObjRender_SetScaleXYZ(obj,Scale,Scale,1);
			yield;
		}
		loop(14)
		{
			yield;
		}
		loop(45)
		{
			ObjRender_SetColor(obj,R*Alpha,G*Alpha,B*Alpha);
			Alpha-=1/45;
			yield;
		}
		Obj_Delete(obj);
	}
}

task DummySpell
{//���ꖳ�G�V�X�e���p
	if(DimensionFlag && GetVirtualKeyState(VK_BOMB)!=KEY_PUSH)
	{
	DimensionFlag=false;
	SetPlayerInvincibilityFrame(150);//���G���Ԃ�ݒ�
	}
	else
	{
	SetPlayerInvincibilityFrame(0);//���G���Ԃ�ݒ�
	}
	let objManage = GetSpellManageObject();
	Obj_Delete(objManage);
	if(OnSpell)
	{
		SetPlayerSpeed(4.5*2,2.0*2);	
	}
	else
	{
		SetPlayerSpeed(4.5*2,2.0*2);
	}
	yield;
	if(OnSpell)
	{
		SetPlayerSpeed(4.5,2.0);	
	}
	else
	{
		SetPlayerSpeed(4.5,2.0);
	}
}