 task Stage1 {
  loop {
   if(title == 1 || title == 2) { //タイトル画面中なら{}を実行
    yield;
   }
   else if(count == 1 && title == 3) {
    PlayMusic(bgm1);
    wait(30);
    hyousei1E(0);
    wait(180);
    hyousei1e(1);
    wait(180);
    hyousei1ee(2, 1);
    wait(300);
    hyousei2e(1);
    wait(500);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\チルノ通常弾１-Easy-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(500);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面ボス-Easy-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 2 && title == 3) {
    PlayMusic(bgm1);
    wait(30);
    hyousei1N(0);
    wait(180);
    hyousei1n(1);
    wait(180);
    hyousei1nn(2, 1);
    wait(300);
    hyousei2n(1);
    wait(500);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\チルノ通常弾１-Normal-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面ボス-Normal-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 3 && title == 3) {
    PlayMusic(bgm1);
    wait(30);
    hyousei1H(0);
    wait(180);
    hyousei1h(1);
    wait(180);
    hyousei1hh(2, 1);
    wait(300);
    hyousei2h(1);
    wait(500);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面中ボス-Hard-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面ボス-Hard-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
   else if(count == 4 && title == 3) {
    PlayMusic(bgm1);
    wait(30);
    hyousei1L(0);
    wait(180);
    hyousei1l(1);
    wait(180);
    hyousei1ll(2, 1);
    wait(300);
    hyousei2l(1);
    wait(500);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面中ボス-Lunatic-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    CreateEnemyBossFromFile(GetCurrentScriptDirectory~"１面\１面ボス-Lunatic-.txt", 0, 0, 0, 0, 0);
    waitZero();
    wait(240);
    ClearStage;
   }
  }
 }

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

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

 function Select(expr, truenum, falsenum) {
  if(expr) {
   return truenum;
  }
  else {
   return falsenum;
  }
 }

 function hyousei1E(way) {
  plus = 1;
  loop(2) {
   wait(180);
   loop(9) {
    wait(18);
    let x = 40;
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Easy-.txt", Select(plus < 0, GetClipMaxX, GetClipMinX) + (x * plus), 0, 2, 90, Select(plus < 0, 1 + way * 2, way * 2));
    x += 24;
    loop(10) {
     wave(9, GetCenterX, GetCenterY, 1, 0, 0, BLUE11, 0, 36);
    }
   }
   plus = -plus;
  }
 }

 function hyousei1e(way) {
  loop(2) {
  let x = GetClipMinX + 10;
  let move = 1;
   wait(120);
   loop(10) {
    wait(30);
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Easy-.txt", x, 0, 2, 90, move * way);
    x += (GetClipMaxX - 10) / 10;
    move += 1;
    if(move == 11) {
     move = 1;
     x = GetClipMinX + 10;
    }
   }
  }
 }

 function hyousei1ee(way, way2) {
  let x = 0;
  loop(way) {
   wait(180);
   loop(10) {
    wait(35);
    loop(way2) {
     CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Easy-.txt", x, GetClipMinY, 2, 90, 0);
     x = rand(GetClipMinX, GetClipMaxX);
    }
   }
  }
 }

 function hyousei1N(way) {
  plus = 1;
  loop(2) {
   wait(180);
   loop(9) {
    wait(18);
    let x = 40;
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Normal-.txt", Select(plus < 0, GetClipMaxX, GetClipMinX) + (x * plus), 0, 2, 90, Select(plus < 0, 1 + way * 2, way * 2));
    x += 24;
   }
   plus = -plus;
  }
 }

 function hyousei1n(way) {
  loop(2) {
  let x = GetClipMinX + 10;
  let move = 1;
   wait(120);
   loop(10) {
    wait(30);
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Normal-.txt", x, 0, 2, 90, move * way);
    x += (GetClipMaxX - 10) / 10;
    move += 1;
    if(move == 11) {
     move = 1;
     x = GetClipMinX + 10;
    }
   }
  }
 }

 function hyousei1nn(way, way2) {
  let x = 0;
  loop(way) {
   wait(180);
   loop(10) {
    wait(35);
    loop(way2) {
     CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Normal-.txt", x, GetClipMinY, 2, 90, 0);
     x = rand(GetClipMinX, GetClipMaxX);
    }
   }
  }
 }

 function hyousei1H(way) {
  plus = 1;
  loop(2) {
   wait(180);
   loop(9) {
    wait(18);
    let x = 40;
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Hard-.txt", Select(plus < 0, GetClipMaxX, GetClipMinX) + (x * plus), 0, 2, 90, Select(plus < 0, 1 + way * 2, way * 2));
    x += 24;
   }
   plus = -plus;
  }
 }

 function hyousei1h(way) {
  loop(2) {
  let x = GetClipMinX + 10;
  let move = 1;
   wait(120);
   loop(10) {
    wait(30);
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Hard-.txt", x, 0, 2, 90, move * way);
    x += (GetClipMaxX - 10) / 10;
    move += 1;
    if(move == 11) {
     move = 1;
     x = GetClipMinX + 10;
    }
   }
  }
 }

 function hyousei1hh(way, way2) {
  let x = 0;
  loop(way) {
   wait(180);
   loop(10) {
    wait(35);
    loop(way2) {
     CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Hard-.txt", x, GetClipMinY, 2, 90, 0);
     x = rand(GetClipMinX, GetClipMaxX);
    }
   }
  }
 }

 function hyousei1L(way) {
  plus = 1;
  loop(2) {
   wait(180);
   loop(9) {
    wait(18);
    let x = 40;
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Lunatic-.txt", Select(plus < 0, GetClipMaxX, GetClipMinX) + (x * plus), 0, 2, 90, Select(plus < 0, 1 + way * 2, way * 2));
    x += 24;
   }
   plus = -plus;
  }
 }

 function hyousei1l(way) {
  loop(2) {
  let x = GetClipMinX + 10;
  let move = 1;
   wait(120);
   loop(10) {
    wait(30);
    CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Lunatic-.txt", x, 0, 2, 90, move * way);
    x += (GetClipMaxX - 10) / 10;
    move += 1;
    if(move == 11) {
     move = 1;
     x = GetClipMinX + 10;
    }
   }
  }
 }

 function hyousei1ll(way, way2) {
  let x = GetCenterX;
  loop(way) {
   wait(180);
   loop(10) {
    wait(35);
    loop(way2) {
     CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精１-Lunatic-.txt", x, GetClipMinY, 2, 90, 0);
     x = rand(GetClipMinX, GetClipMaxX);
    }
   }
  }
 }

 function hyousei2e(way) {
  CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精２-Easy-.txt", GetCenterX, GetClipMinY, 1, 90, way);
 }

 function hyousei2n(way) {
  CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精２-Normal-.txt", GetCenterX, GetClipMinY, 1, 90, way);
 }

 function hyousei2h(way) {
  CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精２-Hard-.txt", GetCenterX, GetClipMinY, 1, 90, way);
 }

 function hyousei2l(way) {
  CreateEnemyFromFile(GetCurrentScriptDirectory~"１面\氷精２-Lunatic-.txt", GetCenterX, GetClipMinY, 1, 90, way);
 }

#include_function ".\１面\変数集.txt"
#include_function ".\１面\wave.txt"