//スペルとダミースペル
task TSpell
{//妖器「銀色のアナザーディメンジョン」 
	OnSpell=true;
	DimensionFlag=true;
	SetPlayerSpeed(0.0,0.0);
	SetPlayerInvincibilityFrame_Special(120);//無敵時間を設定
	let objManage = GetSpellManageObject();
	Obj_Delete(objManage);

	PlaySE(SE_SPELL1);
	//PlaySE(SE_SPELL2);

	OperationEffect;
	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);}
	DimensionFlag=false;

	task AnotherDimension
	{
		DimensionErase;
		loop(30){yield;}
		DimensionEffect;

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

		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,38);
		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;
		}
		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
{//特殊無敵システム用
	if(DimensionFlag && GetVirtualKeyState(VK_BOMB)!=KEY_PUSH)
	{
	DimensionFlag=false;
	SetPlayerInvincibilityFrame(150);//無敵時間を設定
	}
	else
	{
	SetPlayerInvincibilityFrame(0);//無敵時間を設定
	}
	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);
	}
}