//弄らないで下さい、正常に作動しなくなる可能性があります。 


#include_script".\Local.txt"


 function StageA{
 SetCommonDataEx("","bg",0);
  wait(480);
  loop(2){
  loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",minx+50+30*a,miny-30,2,90,0);
       }
    wait(20);
       }
    wait(10);
   loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",maxx-50-30*a,miny-30,2,90,1);
       }
    wait(20);
       }
      wait(10);
     }      
  wait(120);   
  loop(2){
  ascent(a in 0..13){
  enemy(csd~".\EnemyData\Enemy02.txt",maxx-20-(maxx-minx)/11*a,miny-30,0,90,0);
     wait(20);
      }
     wait(60);
      }
   loop(2){
  ascent(a in 0..13){
  enemy(csd~".\EnemyData\Enemy02.txt",minx+20+(maxx-minx)/11*a,miny-30,0,90,0);
     wait(20);
         }
      }  
   wait(60);    
   enemy(csd~".\EnemyData\Enemy03.txt",cx,miny-20,0,90,0);
    wait(180);
   enemy(csd~".\EnemyData\Enemy03.txt",maxx-50,miny-20,0,90,0);
   enemy(csd~".\EnemyData\Enemy03.txt",minx+50,miny-20,0,90,0);
    wait(150); 
  enemy(csd~".\EnemyData\Enemy04.txt",cx,miny-20,0,90,0);  
   wait(120);
  enemy(csd~".\EnemyData\Enemy04.txt",minx+100,miny-20,0,90,1);
  wait(120);
  enemy(csd~".\EnemyData\Enemy04.txt",maxx-100,miny-20,0,90,0);
  wait(120);
  enemy(csd~".\EnemyData\Enemy04.txt",cx,miny-20,0,90,1);   
  wait(600);  
  enemy(csd~".\EnemyData\Enemy05.txt",cx,miny-20,0,90,0); 
  wait(1080);    
  boss(csd~".\EnemyData\BossCirno.txt",minx-60,miny+100,0,0,0);
  waitnext; 
  wait(60);
  enemy(csd~".\EnemyData\Enemy06.txt",minx+60,miny-20,0,90,0); 
   wait(20);
  enemy(csd~".\EnemyData\Enemy06.txt",maxx-60,miny-20,0,90,0); 
   wait(20);
  enemy(csd~".\EnemyData\Enemy06.txt",cx,miny-20,0,90,0); 
   wait(90);
  enemy(csd~".\EnemyData\Enemy06.txt",minx-60,miny+80,0,90,4); 
   wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",maxx+60,miny+80,0,90,5); 
    wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",minx+100,miny-20,0,90,0);
   wait(75);
 enemy(csd~".\EnemyData\Enemy06.txt",minx-60,miny+120,0,90,4); 
   wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",maxx+60,miny+120,0,90,5); 
    wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",minx-60,miny+80,0,90,4); 
   wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",maxx+60,miny+80,0,90,5); 
    wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",minx+100,miny-80,0,90,0); 
   wait(10);
  enemy(csd~".\EnemyData\Enemy06.txt",maxx-100,miny-80,0,90,0); 
    wait(60);
  ascent(a in 0..4){
   enemy(csd~".\EnemyData\Enemy06.txt",cx-60-20*a,miny-80,0,90,0);
    wait(4);
   enemy(csd~".\EnemyData\Enemy06.txt",cx+60+20*a,miny-80,0,90,0);
    wait(4);
     }
   wait(30);
  ascent(a in 0..5){
   enemy(csd~".\EnemyData\Enemy06.txt",minx-100,miny+100+20*a,0,90,4);
    wait(4);
   enemy(csd~".\EnemyData\Enemy06.txt",maxx+100,miny+100+20*a,0,90,5);
    wait(4);
     }
   wait(90);  
 loop(2){
  loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",minx+50+30*a,miny-30,2,90,10);
       }
    wait(15);
       }
   loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",maxx-50-30*a,miny-30,2,90,11);
       }
    wait(15);
       }
     }  
  wait(120); 
  E(60);  
  wait(300);
  E(55); 
  wait(275);
  E(50);
   wait(250);
   E(45);
  wait(525);
  E(20);
  wait(10);
  E(20);
  wait(420); 
  loop(2){
  loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",minx+50+30*a,miny-30,2,90,20);
       }
    wait(15);
       }
   loop(9){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy01.txt",maxx-50-30*a,miny-30,2,90,21);
       }
    wait(15);
       }
     }  
  wait(60);
  SetCommonDataEx("","bg",-1);
  loop(4){E(20); wait(5);}
 SetCommonDataEx("","bg",3);
   wait(360);
  enemy(csd~".\EnemyData\Enemy05.txt",cx,miny-20,0,90,100); 
  wait(1080); 
  boss(csd~".\EnemyData\BossMugetu.txt",minx-60,miny+100,0,0,0);
  waitnext;
  wait(60);  
    }

  task E(w){
  loop(2){
   enemy(csd~".\EnemyData\Enemy07.txt",rand(minx+48,maxx-48),miny+rand(40,120),0,90,0);
    wait(w);
      }
   ascent(a in 1..4){
    enemy(csd~".\EnemyData\Enemy07.txt",rand(minx+48,maxx-48),miny+rand(40,120),0,90,a);
   wait(w); 
       }
    }


 function StageB{
 SetCommonDataEx("","bg",5);
  wait(480);
  loop(3){
  loop(5){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy101.txt",minx+50+30*a,miny-30,2,90,0);
       }
    wait(15);
       }
  wait(20);
   loop(5){
  ascent(a in 0..2){
  enemy(csd~".\EnemyData\Enemy101.txt",maxx-50-30*a,miny-30,2,90,1);
       }
    wait(15);
       }
   wait(20);
     }      
    wait(180);
  let w = 120;
   loop(5){
  ascent(a in 0..5){
  enemy(csd~".\EnemyData\Enemy102.txt",minx-10-30*a,miny+30,0,0,0);
       } 
    wait(w);
     ascent(a in 0..5){
  enemy(csd~".\EnemyData\Enemy102.txt",maxx+10+30*a,miny+30,0,0,1);
       }
     wait(w);
  w -= 30;
     }
    wait(360);  
  ascent(a in 0..3){
   enemy(csd~".\EnemyData\Enemy103.txt",cx-150+30*a,miny+120,0,0,0); 
   enemy(csd~".\EnemyData\Enemy103.txt",cx+150-30*a,miny+120,0,0,0); 
   wait(15);
     }
   wait(240);
 let w = 20;
  loop(80){
  enemy(csd~".\EnemyData\Enemy104.txt",rand(minx+64,maxx-64),miny-30,0,0,0); 
  wait(w);
 w -= 0.5;
  if(w < 3){w = 3;}
     }   
  loop(4){
   enemy(csd~".\EnemyData\Enemy105.txt",minx+10,miny+10,3,0,0);
    enemy(csd~".\EnemyData\Enemy105.txt",maxx-10,miny+10,3,90,0); 
    enemy(csd~".\EnemyData\Enemy105.txt",maxx-10,maxy-10,3,180,0); 
   enemy(csd~".\EnemyData\Enemy105.txt",minx+10,maxy-10,3,0,0);  
   wait(100);
     }
   wait(660); 
  enemy(csd~".\EnemyData\Enemy103.txt",cx,miny+90,0,0,1); 
   wait(120);
   loop(4){
   enemy(csd~".\EnemyData\Enemy106.txt",minx+60,miny,0,0,0); 
   wait(60);
  enemy(csd~".\EnemyData\Enemy106.txt",maxx-60,miny,0,0,1); 
   wait(60);
     }
   wait(60);
    let w = 120;
   loop(3){
  ascent(a in 0..5){
  enemy(csd~".\EnemyData\Enemy102.txt",minx-10-30*a,miny+30,0,0,0);
       } 
    wait(w);
     ascent(a in 0..5){
  enemy(csd~".\EnemyData\Enemy102.txt",maxx+10+30*a,miny+30,0,0,1);
       }
     wait(w);
  w -= 30;
     }
   wait(240);   
   loop(10){
  enemy(csd~".\EnemyData\Enemy107.txt",cx,miny-20,2,150,0);
    wait(15);
    }
  wait(90);
     loop(10){
  enemy(csd~".\EnemyData\Enemy107.txt",minx+60,miny-20,2,150,0);
    wait(15);
    }
   wait(60);
    loop(10){
  enemy(csd~".\EnemyData\Enemy107.txt",maxx-60,miny-20,2,150,0);
    wait(15);
    }
   wait(300);   
 DeleteAllEnemyWithoutBoss;
  DeleteEnemyShot(ALL); 
  boss(csd~".\EnemyData\BossYuka.txt",cx,miny+120,0,0,0);
  waitnext;    
  enemy(csd~".\EnemyData\BossYuka02.txt",cx,miny+120,0,0,0);
  waitnext; 
   let w = 20;
  loop(60){
  enemy(csd~".\EnemyData\Enemy108.txt",rand(minx+64,maxx-64),miny-30,0,0,0); 
  wait(w);
 w -= 0.5;
  if(w < 8){w = 8;}
     }
  wait(180);   
 enemy(csd~".\EnemyData\Enemy103.txt",cx,miny+90,0,0,2); 
  wait(90);
   loop(4){
   enemy(csd~".\EnemyData\Enemy106.txt",maxx-60,miny,0,0,3); 
   wait(60);
  enemy(csd~".\EnemyData\Enemy106.txt",minx+60,miny,0,0,2); 
   wait(60);
     }
  wait(570); 
   SetCommonDataEx("","bg",-1);
  wait(30);
    SetCommonDataEx("","bg",8);
 ascent(a in 0..4){
   ascent(b in 0..4){
  enemy(csd~".\EnemyData\Enemy103.txt",minx+32+45*a,miny+32+130*b,0,0,3); 
  enemy(csd~".\EnemyData\Enemy103.txt",maxx-32-45*a,miny+32+130*b,0,0,3); 
     wait(30);
       }
     }
    wait(180);
  let basex = GetPlayerX; let basey = GetPlayerY;
   ascent(a in 0..4){
     enemy(csd~".\EnemyData\Enemy103.txt",minx+120+(basex-minx-120)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
    wait(30); 
    }
    let basex = GetPlayerX; let basey = GetPlayerY;
     ascent(a in 0..4){
     enemy(csd~".\EnemyData\Enemy103.txt",minx+32+(basex-minx-32)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
    wait(30); 
    }
   let basex = GetPlayerX; let basey = GetPlayerY;
     ascent(a in 0..4){
     enemy(csd~".\EnemyData\Enemy103.txt",maxx-32+(basex-maxx+32)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
    wait(30); 
    }
    let basex = GetPlayerX; let basey = GetPlayerY;
     ascent(a in 0..4){
     enemy(csd~".\EnemyData\Enemy103.txt",maxx-120+(basex-maxx+120)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
    wait(30); 
    }
     let basex = GetPlayerX; let basey = GetPlayerY;
       ascent(a in 0..6){
  if(a >= 0 && a <= 3){
     enemy(csd~".\EnemyData\Enemy103.txt",maxx-120+(basex-maxx+120)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
     enemy(csd~".\EnemyData\Enemy103.txt",minx+120+(basex-minx-120)/3*a,miny+32+(basey-miny-32)/3*a,0,0,3);
     }
  if(a >= 2 && a <= 5){
    enemy(csd~".\EnemyData\Enemy103.txt",minx+32+(basex-minx-32)/3*(a-2),miny+32+(basey-miny-32)/3*(a-2),0,0,3);
    enemy(csd~".\EnemyData\Enemy103.txt",maxx-32+(basex-maxx+32)/3*(a-2),miny+32+(basey-miny-32)/3*(a-2),0,0,3);
    }
    wait(30); 
    } 
   wait(300);
  DeleteAllEnemyWithoutBoss;
  DeleteEnemyShot(ALL);  
  boss(csd~".\EnemyData\BossMugetu2.txt",cx,miny+100,0,0,0);
  waitnext;  
  boss(csd~".\EnemyData\BossGengetu.txt",cx,miny+600,0,0,0);
   waitnext;
  }


function enemy(text,x,y,speed,angle,arg){
       CreateEnemyFromFile(text,x,y,speed,angle,arg);
            }

   function boss(text,x,y,speed,angle,arg){
       CreateEnemyBossFromFile(text,x,y,speed,angle,arg);
            }

   function wait(frame){
	loop(frame){yield};
		}
   function waitnext{
	while(GetEnemyNum() != 0){yield;}
		}	