task Stage2{

loop{
function Wait(let frame){loop(frame){yield};}
function WaitForZeroEnemy{while(GetEnemyNum != 0){yield;}}	
Wait(60);
StageNo=1;
PlayMusic("script\BGM\No.04.mp3");
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,90,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,150,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,190,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",430,60,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",430,90,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",430,120,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",430,150,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",430,190,0,0,0);
WaitForZeroEnemy;
Wait(120);
StageTitle;
Wait(700);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-100,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+100,0,0,0,0);
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(120);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-50,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+50,0,0,0,0);
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
WaitForZeroEnemy;
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx-150,0,0,0,0);
Wait(60);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx+150,0,0,0,0);
Wait(60);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,90,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,150,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,190,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,220,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,250,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,280,0,0,0);
Wait(50);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,310,0,0,0);
WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-50,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+50,0,0,0,0);
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-100,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+100,0,0,0,0);
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-150,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+150,0,0,0,0);
WaitForZeroEnemy;
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
WaitForZeroEnemy;
Wait(150);
if(GetCommonData("Rank")=="E"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossE.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="N"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossN.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="H"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossH.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="L"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-MiddleBossL.txt",0,0,0,0,0);
} 
WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx-150,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx+150,0,0,0,0);
Wait(100);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-50,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+50,0,0,0,0);
Wait(100);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,120,0,0,0);
Wait(130);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx-150,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-全方位弾.txt",Cx+150,0,0,0,0);
Wait(110);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-150,0,0,0,0);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+150,0,0,0,0);
WaitForZeroEnemy;
Wait(150);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(140);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(130);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(120);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(110);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(100);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(80);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(70);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
Wait(60);
CreateEnemyFromFile("script\Script-Stage1\1面-ランダム拡散.txt",rand(Cx-150,Cx+150),0,0,0,0);
WaitForZeroEnemy;
Wait(120);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-150,0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+150,0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+100,0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx+50,0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-100,0,0,0,0);
Wait(90);
CreateEnemyFromFile("script\Script-Stage1\1面-扇状弾1.txt",Cx-50,0,0,0,0);
WaitForZeroEnemy;
Wait(160);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",0,120,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い1.txt",0,60,0,0,0);
Wait(35);
CreateEnemyFromFile("script\Script-Stage1\1面-自機狙い2.txt",0,120,0,0,0);
WaitForZeroEnemy;
Wait(160);
if(GetCommonData("Rank")=="E"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossE.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="N"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossN.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="H"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossH.txt",0,0,0,0,0);
}else if(GetCommonData("Rank")=="L"){
CreateEnemyBossFromFile("script\Script-1Boss\Frolir-BossL.txt",0,0,0,0,0);
} 
WaitForZeroEnemy;
FadeOutMusic("script\BGM\No.03.mp3",20);
	
	
	
	
	
	
	

yield;	
}




task StageTitle{
let X=GetCenterX-150;
let Y=GetCenterY-100;
let Img1="script\Script-Stage1\StageTitle-1.png";
let rect01=0;
let rect02=0;
let rect03=428;
let rect04=187;
let Layer=7;
let W=(rect03-rect01)/2;
let H=(rect04-rect02)/2;
let Angle1=0;
let Scale=1;
let Frame1=0;
let Set1=0;
let Set2=0;
let Set3=0;
let Set4=0;
let Set5=0;
let Angle2=rand(0,180)+40;
let Angle3=rand(0,180)+40;
let Alpha=0;
let Obj=Obj_Create(OBJ_EFFECT);
LoadGraphic(Img1);
ObjEffect_SetTexture(Obj,Img1);
ObjEffect_SetRenderState(Obj,ALPHA);
ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLEFAN);
ObjEffect_CreateVertex(Obj,4);
ObjEffect_SetLayer(Obj,Layer);
Obj_SetPosition(Obj,X,Y);
ObjEffect_SetAngle(Obj,0,0,0);
ObjEffect_SetScale(Obj,1.0,1.0);
ObjEffect_SetVertexXY(Obj,0,-W,-H);
ObjEffect_SetVertexXY(Obj,1,W,-H);
ObjEffect_SetVertexXY(Obj,2,W,H);
ObjEffect_SetVertexXY(Obj,3,-W,H);
ObjEffect_SetVertexUV(Obj,0,rect01,rect02);
ObjEffect_SetVertexUV(Obj,1,rect03,rect02);
ObjEffect_SetVertexUV(Obj,2,rect03,rect04);
ObjEffect_SetVertexUV(Obj,3,rect01,rect04);
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);
Obj_SetSpeed(Obj,1);
Obj_SetAngle(Obj,0);
loop{
Frame1++;
ObjEffect_SetAngle(Obj,Angle1,Angle1,Angle1);
ObjEffect_SetScale(Obj,Scale,Scale);
ObjEffect_SetVertexColor(Obj,0,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,1,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,2,Alpha,255,255,255);
ObjEffect_SetVertexColor(Obj,3,Alpha,255,255,255);
if(Frame1==20){
Obj_SetSpeed(Obj,2);
}
if(Frame1==30){
Obj_SetSpeed(Obj,3);
}
if(Frame1==100){
Obj_SetSpeed(Obj,2);
}
if(Frame1==110){
Obj_SetSpeed(Obj,1);
}
if(Frame1==120){
Obj_SetSpeed(Obj,0);
}
if(Frame1==360){
Set1=1;
}
if(Frame1==600){
Obj_Delete(Obj);
break;
}
if(Set1==1){
if(Alpha<0){

}else{
Alpha-=1;
}
}else{
if(Alpha>255){

}else{
Alpha+=5;
}
}

yield;	
}
}








	
}