#東方弾幕風
#Title[ユナ通常〜Hard]
#Text[大型弾の圧迫が強くなります。]
#ScriptVersion[2]

script_enemy_main {
 let img = "script\img\ExRumia.png";
 let frame     =  0;
 let angleBase = 90;

 @Initialize {
  SetX(GetCenterX);
  SetY(GetCenterY - 120);
  SetLife(3000);
  SetTimer(99);

  LoadGraphic(img);
  SetTexture(img);
  SetGraphicRect(64, 0, 128, 64);

  TMain;
 }

 @MainLoop {
  SetCollisionA(GetX, GetY, 24);
  SetCollisionB(GetX, GetY, 24);

  yield;
 }

 @DrawLoop {
  DrawGraphic(GetX, GetY);
 }

 @Finalize {
  DeleteGraphic(img);
 }

 //以下タスク(マイクロスレッド)

 task TMain {
  yield;

  TMove;
  TShot;
  TShot2; //何個足してもおｋ
  TShot3; 
 
  
 }

 task TMove {

 SetShotDirectionType(PLAYER);

  yield;
 }

 task TShot {
  let angle = 0;
  let xMove = 1;
  let pet = 0;
  yield;

  loop {
   loop(2) { yield; }
   CreateShot01(GetX - xMove, GetY+90, 3, angle, ORANGE22, 90);  
   angle += 16.5;

   pet += 1;
   if(pet < 200) {
    xMove += 1;
   }
   if(pet >= 200) {
    xMove -= 1;
   }
   if(pet > 400) {
    pet = 0;
   }
  }
 }

 task TShot2 {

 SetShotDirectionType(PLAYER);

  let angle = 0;
  let xMove = 1;
  let pet = 0;
  yield;

  loop {
   loop(2) { yield; }
   CreateShot01(GetX + xMove, GetY+90, 3, angle, ORANGE22, 90);  
   angle -= 16.5;

   pet += 1;
   if(pet < 200) {
    xMove += 1;
   }
   if(pet >= 200) {
    xMove -= 1;
   }
   if(pet > 400) {
    pet = 0;
   }
  }
 }

 task TShot3 {
      
  SetShotDirectionType(PLAYER);

  let angle = 0;
  let yMove = 0;
  let pet = 0;

  yield;

  loop { //一番上の夕日
   loop(2) { yield; }
   CreateShot01(GetX , GetY + yMove + 90, 3, angle, ORANGE03, 90);
   angle -= 15;

   pet += 1;
   if(pet < 200) {
    yMove -= 180 / 200;
   }
   if(pet >= 200) {
    yMove += 180 / 200;
   }
   if(pet >= 400) {
    pet = 0;
   }
  }
 }



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

}