
script_spell MicroHole //魔符「マイクロホール」スクリプト
{
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
    @Initialize {
	BombX=GetPlayerX;
	BombY=GetPlayerY;
        SetPlayerInvincibility(120);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	Border;
	Nebura;
        loop(90){yield;}
        End;
    }

task Border
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(15)
	{
		BorderEffect(r1,r2,angle,Alpha);
		if(r1<50)
		{
			r1+=6;
			r2+=6;
		}
		angle+=6;
		loop(3){yield;};
	}
	loop(15)
	{
		BorderEffect(r1,r2,angle,Alpha);
		r1-=3;
		r2-=3;
		angle+=6;
		Alpha-=100/60;
		loop(3){yield;};
	}
}

task Nebura
{
		let r=0;
		let VertexNum=16;
		let UVX=rand(0,512);
		let UVY=rand(0,512);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(45)
		{
			if(r<250)
			{
				r+=2;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.4,true);
			UVX+=3;
			UVY+=3;
			yield;
		}

		let Alpha=100;
		loop(45)
		{
			if(r>0)
			{
				r-=1;
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,196,196,255);
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,0.4,true);
			UVX+=3;
			UVY+=3;
			Alpha-=45/50;
			yield;
		}
		Obj_Delete(obj);
}

task BorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);
	//	let Alpha=100;
		//let angle=0;

		let StandardX=GetCenterX;
		let StandardY=GetCenterY+32;

		loop(5)
		{
		if(r1<50)
		{
			r1+=2.5;
			r2+=2.5;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}


}

script_spell Stardust //魔符「スターダスト」スクリプト
{
	let imgNebura = GetCurrentScriptDirectory~"..\img\nebura.png";
let imgMarisaShot = GetCurrentScriptDirectory~"..\img\Marisa_shots.png";
	let imgBorderLine = GetCurrentScriptDirectory~"..\img\SampleEC01a.png";
let SE=["se\seBomb_ReimuB.wav"];
let BombX;
let BombY;
    @Initialize {
	BombX=GetCenterX;
	BombY=GetCenterY;
        SetPlayerInvincibility(270);
	TMain;
    }

    @Finalize {
    }

    @MainLoop {
	CollectItems;
        yield;
    }

   task TMain {
//	PlaySE(SE[0]);
	StartStar;
	loop(60){yield;}
	Border;
	Star;
	Nebura;
        loop(180){yield;}
        End;
    }

task StartStar
{
	let X=GetPlayerX;
	let Y=GetPlayerY;
	let i=0;
	let r=240;
	let angle=rand(0,360);
	loop(60)
	{
		ascent(let k in 0..7)
		{
			StartStarEffect(X-((X-BombX)/60)*i,Y-((Y-BombY)/60)*i,r,angle+360/7*k,9+k);
		}
	yield;
	i+=1;
	r-=4;
	angle+=4.5;
	}
}
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);
}

task Nebura
{
		let r=0;
		let VertexNum=16;
		let UVX=rand(0,256);
		let UVY=rand(0,256);
  		let obj = Obj_Create(OBJ_SPELL);
		Obj_SetPosition(obj,BombX,BombY);
		ObjEffect_SetTexture(obj, imgNebura);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, VertexNum);

		ObjEffect_SetVertexXY(obj, 0, 0, 0);

		ObjEffect_SetVertexUV(obj, 0,0,0);
		ObjEffect_SetLayer(obj,2);

		ascent(let i in 0..VertexNum)
		{
		ObjEffect_SetVertexColor(obj,i,100,196,196,255);
		}

		loop(120)
		{
		if(r<250)
		{
			r+=8;
		}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,3,true);
			UVX+=3;
			UVY+=3;
			yield;
		}

		loop(30)
		{
		if(r>0)
		{
			r-=8;
		}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexXY(obj, i,r*cos(360/VertexNum*i),r*sin(360/VertexNum*i));
			}
			ascent(let i in 0..VertexNum)
			{
			ObjEffect_SetVertexUV(obj, i,UVX+r*cos(360/VertexNum*i),UVY+r*sin(360/VertexNum*i));
			}
			ObjSpell_SetIntersecrionCircle(obj,BombX,BombY,r,3,true);
			UVX+=3;
			UVY+=3;
			yield;
		}
		Obj_Delete(obj);
}

task Star
{
let t=0;
loop(60)
{
	StarEfect(9+t%7);
	loop(2){yield;};
	t+=1;
}
}

task StarEfect(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 Xangle=rand(0,360);
		let Yangle=rand(0,360);
		let Zangle=rand(0,360);

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(-10,10);

		let Scale=0.1;

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,BombX,BombY);
		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);
		}

		let speed=rand(6,10);
		let angle=rand(0,360);
		Obj_SetSpeed(obj,speed);
		Obj_SetAngle(obj,angle);

		let ShadowCount=0;
		while(!Obj_BeDeleted(obj))
		{
			if(ShadowCount%3==0 && GetCommonDataDefault("LightMode",0)==0)
			{
			StarShadowEfect(Obj_GetX(obj),Obj_GetY(obj),speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B);
			}
			ObjEffect_SetScale(obj,Scale,Scale);
			ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);
			Xangle+=XanglePlus;
			Yangle+=YanglePlus;
			Zangle+=ZanglePlus;
			Scale+=0.05;
			ShadowCount++;
			yield;
		}
}


task StarShadowEfect(X,Y,speed,angle,Scale,Xangle,Yangle,Zangle,R,G,B)
{

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,X,Y);
		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);

		let Alpha=100;
		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
		}

		ObjEffect_SetAngle(obj,Xangle,Yangle,Zangle);

		loop(3)
		{
			ObjEffect_SetScale(obj,Scale,Scale);
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			Scale+=0.05;
			Alpha-=20;
			yield;
		}
		Obj_Delete(obj);
}

task Border
{
let r1=-25;
let r2=25;
let angle=0;
let Alpha=100;
	loop(40)
	{
		BorderEffect(r1,r2,angle,Alpha);
		if(r1<200)
		{
			r1+=24;
			r2+=24;
		}
		angle+=6;
		loop(3){yield;};
	}
	loop(10)
	{
		BorderEffect(r1,r2,angle,Alpha);
		r1-=24;
		r2-=24;
		angle+=6;
		Alpha-=100/60;
		loop(3){yield;};
	}
}

task BorderEffect(r1,r2,angle,Alpha)
{
		let randvertex=rand_int(0,5);
		let VertexNum=16;
		let Radius=[r1,r2];
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj,imgBorderLine);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj,VertexNum);
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{
			ObjEffect_SetVertexXY(obj, i-randvertex, Radius[i%2]*cos(360/(VertexNum-2)*i), Radius[i%2]*sin(360/(VertexNum-2)*i));
		}
		ascent(let i in 0+randvertex..VertexNum+randvertex)
		{	
			ObjEffect_SetVertexUV(obj, i-randvertex,  256/(VertexNum)*i,  16*(i%2));
		}


		ObjEffect_SetLayer(obj,3);

		let Scale=1;
		let Zangle=0;
		ObjEffect_SetScale(obj,Scale,Scale);
		Obj_SetPosition(obj,BombX,BombY);

		loop(5)
		{
		if(r1<250)
		{
			r1+=10;
			r2+=10;
			Radius=[r1,r2];
		}
		ascent(let i in 0..VertexNum)
		{
			ObjEffect_SetVertexXY(obj, i, Radius[i%2]*cos(360/(VertexNum-2)*i+angle), Radius[i%2]*sin(360/(VertexNum-2)*i+angle));
		}
		ascent(let i in 0..VertexNum)
		{			
			ObjEffect_SetVertexColor(obj, i,Alpha,255,0,255*(i%3));
		}
		ObjEffect_SetScale(obj,Scale,Scale);
		angle+=2;
		Alpha-=20;
		Scale+=0.01;
		yield;
		}
		Obj_Delete(obj);
}

}