#e[Stage]
#Title[NWL()]
#Text[ϑzx񌴈ẴIWiXe[Wł]
#ScriptVersion[2]

script_stage_main {
 let title = true; //^CgȂtrue
 let titleimg = GetCurrentScriptDirectory~".\img\ExRumiaBack.png"; //^Cg摜
 let count = 1; //J[\̏lPɂ

 @Initialize {
  LoadGraphic(titleimg);

  TStage;
 }

 @MainLoop {
  if(title == true) { //^CgʒȂ{}s
   ForbidShot(true); //Vbg֎~
   ForbidBomb(true); //{֎~
   SetPlayerX(GetCenterX); //vC[xWŒ
   SetPlayerY(GetClipMaxY); //vC[yWŒ
   if(GetKeyState(VK_DOWN) == KEY_PUSH){ //L[ꂽ{}s
    if(count == 1) { //J[\Pꍇ{}s
     count = 2;
    }
    else if(count == 2) { //Qꍇ{}s
     count = 3;
    }
    else if(count == 3) { //Rꍇ{}s
     count = 4;
    }
    else if(count == 4) {
     count = 5;
    }
    else if(count == 5) {
     count = 1;
    }
   }
   else if(GetKeyState(VK_SHOT) == KEY_PUSH) { //VbgL[ꂽ{}s
    if(count == 1) { //Pꍇ
     title = false; //^CgʏI
    }
    else if(count == 2) {
     title = false;
    }
    else if(count == 3) {
     title = false;
    }
    else if(count == 4) {
     title = false;
    }
    else if(count == 5) {
     ClearStage; //NA
    }
   }
  }
  else if(title == false) { //^CgȂꍇ
   ForbidShot(false); //Vbg
   ForbidBomb(false); //{
  }

  yield;
 }

 @Finalize {
  DeleteGraphic(titleimg);
 }

 @DrawTopObject {
  if(title == true) {
   SetTexture(titleimg); //^Cg摜Zbg
   SetGraphicRect(0, 0, 384, 448);
   DrawGraphic(GetCenterX, GetCenterY);
   DrawText("", 50, 40 * count, 18, 255);
   DrawText("Easy", 100, 40, 18, 255);
   DrawText("Normal", 100, 80, 18, 255);
   DrawText("Hard", 100, 120, 18, 255);
   DrawText("Lunatic", 100, 160, 18, 255);
   DrawText("ϋA", 100, 200, 18, 255);
  }
 }

 task TStage {
  loop {
   if(title == true) { //^CgʒȂ{}s
    yield;
   }
   else if(count == 1 && title == false) {
    wait(60);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"`mʏeP-Easy-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 2 && title == false) {
    wait(60);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"`mʏeP-Normal-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 3 && title == false) {
    wait(60);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Pʒ{X-Hard-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 4 && title == false) {
    wait(60);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Pʒ{X-Lunatic-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
  }
 }

 function wait(w) {
  loop(w) { yield; }
 }

 function waitZero() {
  while(GetEnemyNum() != 0) { yield; }
 }

}