let S7_imgBACK	= csd~"img\7001.png";
let S7_imgTITLE	= csd~"img\TITLE7.png";
let S7_imgBOSST	= csd~"img\CAUTION.png";
let S7_imgEF	= csd~"img\7002.png";

sub STAGE7T{
	LoadGraphic(S7_imgBACK);
	LoadGraphic(S7_imgTITLE);
	LoadGraphic(S7_imgBOSST);
	LoadGraphic(S7_imgEF);

	SetCommonData("STAGE",7);
	SetCommonData("Sfade",1);

	function Wait(let frame){loop(frame){yield;}}
	function WaitForZeroEnemy(){while(GetEnemyNum()!=0){yield;}}

	Wait(100);
	PlayMusic(GetCurrentScriptDirectory~"BGM\bgm7a.mp3");
	SetCommonData("EFC",7);
	TITLE7;
	Wait(250);
	SetCommonData("Sfade",0);
        loop(10){
		CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy73_T.txt",rand(50,200),rand(50,200),0,0,0);
		Wait(20);
        	}
	Wait(50);
	let i=0;
	loop(10){
		CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy73_T.txt",rand(248,398),rand(50,200),0,0,0);
		Wait(20);
		}
	WaitForZeroEnemy();//敵が消えるまで停止
	Wait(100);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyYuYu_T.txt",0,0,0,0,0);
	Wait(1400);
	FadeOutMusic(GetCurrentScriptDirectory~"BGM\bgm7a.mp3",25);
	Wait(50);
	OVER(1,-224,224,-50,50,0,447,0,99,25,100,70);
	OVER(2,-224,224,-50,50,0,447,0,99,25,100,70);
	OVER(3,-224,224,-50,50,0,447,0,99,25,100,70);
	Wait(150);
	DeleteEnemyShotInCircle(SHOT,224,240,500);
	PlayMusic(GetCurrentScriptDirectory~"BGM\bgm7b.mp3");
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"幽々子連続_T.txt",0,0,0,0,0);
	WaitForZeroEnemy();//敵が消えるまで停止
	Wait(200);
	SetCommonData("EFC",0);
	PlaySE("seSuperNaturalBorder2.wav");
	OVER(1,-224,224,-50,50,0,447,100,199,25,125,70);
	OVER(2,-224,224,-50,50,0,447,100,199,25,125,70);
	OVER(3,-224,224,-50,50,0,447,100,199,25,125,70);
	Wait(50);
	FadeOutMusic(GetCurrentScriptDirectory~"BGM\bgm7b.mp3",20);
	SetCommonData("Sfade",1);
	Wait(400);
	DeleteGraphic(S7_imgBACK);
	DeleteGraphic(S7_imgTITLE);
	DeleteGraphic(S7_imgBOSST);
	DeleteGraphic(S7_imgEF);

// ========== ステージ１用関数やタスク ========= //
task TITLE7{
	let obj=Obj_Create(OBJ_EFFECT);
	let Talpha=0;
	let csd=GetCurrentScriptDirectory;

	ObjEffect_SetLayer(obj,3);
	ObjEffect_SetTexture(obj,S7_imgTITLE);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetRenderState(obj,ALPHA);

	ObjEffect_SetVertexXY(obj,0,-163,-40);
	ObjEffect_SetVertexXY(obj,1,-163,40);
	ObjEffect_SetVertexXY(obj,2,163,-40);
	ObjEffect_SetVertexXY(obj,3,163,40);

	ObjEffect_SetVertexUV(obj,0,0,0);
	ObjEffect_SetVertexUV(obj,1,0,80);
	ObjEffect_SetVertexUV(obj,2,326,0);
	ObjEffect_SetVertexUV(obj,3,326,80);

        loop(51){
		ObjEffect_SetVertexColor(obj,0,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,1,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,2,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,3,Talpha*5,255,255,255);
		Obj_SetPosition(obj,170+Talpha/2,150);
		Talpha++;
		yield;
		}
        loop(150){yield;}
        loop(51){
		ObjEffect_SetVertexColor(obj,0,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,1,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,2,Talpha*5,255,255,255);
		ObjEffect_SetVertexColor(obj,3,Talpha*5,255,255,255);
		Obj_SetPosition(obj,170+Talpha/2,150);
		Talpha--;
		yield;
		}
	Obj_Delete(obj);
	}

task OVER(AP,Xmin,Xmax,Ymin,Ymax,XA,XB,YA,YB,LA,LB,YC){
	let obj=Obj_Create(OBJ_EFFECT);
	let big1=0;
	let big2=0;
	let csd=GetCurrentScriptDirectory;
	let imgCAUTION=csd~"img\CAUTION.png";

	ObjEffect_SetLayer(obj,3);
	ObjEffect_SetTexture(obj,imgCAUTION);
	ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj,4);
	ObjEffect_SetRenderState(obj,ALPHA);
	Obj_SetPosition(obj,GetCenterX,GetCenterY-YC);

	ObjEffect_SetVertexXY(obj,0,Xmin,Ymin);
	ObjEffect_SetVertexXY(obj,1,Xmin,Ymax);
	ObjEffect_SetVertexXY(obj,2,Xmax,Ymin);
	ObjEffect_SetVertexXY(obj,3,Xmax,Ymax);

	ObjEffect_SetVertexUV(obj,0,XA,YA);
	ObjEffect_SetVertexUV(obj,1,XA,YB);
	ObjEffect_SetVertexUV(obj,2,XB,YA);
	ObjEffect_SetVertexUV(obj,3,XB,YB);

	PlaySE("seSuperNaturalBorder2.wav");
        loop(LA){
		big1++;
		ObjEffect_SetScale(obj,2-big1*0.04,big1*0.04);
		ObjEffect_SetVertexColor(obj,0,255,255,255,255);
		ObjEffect_SetVertexColor(obj,1,255,255,255,255);
		ObjEffect_SetVertexColor(obj,2,255,255,255,255);
		ObjEffect_SetVertexColor(obj,3,255,255,255,255);
		yield;
		}
        loop(LB){yield;}
        loop(50){
		big2++;
		ObjEffect_SetScale(obj,1+0.004*AP*big2,1+0.004*AP*big2);
		ObjEffect_SetVertexColor(obj,0,255-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,1,255-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,2,255-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,3,255-4*big2,255,255,255);
		yield;
		}
	Obj_Delete(obj);
	}
}