#TouhouDanmakufu
#Title[Boss War' NSC01]
#Text[Boss du stage 2, 1ere NSC]
#Image[]
#BGM[script\DanMUku\Stage2\War.mp3]
#Player[script\DanMUku\Joueur\KorA\KorHosik.txt, script\DanMUku\Joueur\KorB\KorB.txt, script\DanMUku\Joueur\KorC\KorC.txt]
#ScriptVersion[2]

script_enemy_main
{    
    let imgEnemy ="script\DanMUku\Stage2\Image\WaruigiN.png";
    let count=-120;
    let angle=0;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let frame=0;
    let a=0;
    let z = 0;
    let w = 0.5;

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
            SetLife(3000);
            SetTimer(16);
            SetInvincibility(160);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120);        
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
if(count==100)
{
a=GetAngleToPlayer+2;
loop(36)
{
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a+20, 100);
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a-20, 106);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a+10, 120);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a-10, 126);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a+20, 100);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a-20, 106);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a+10, 120);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a-10, 126);
a+=10;
}
}
if(count==150)
{
frame=1;
}
if(count==152)
{
     frame=0;
}
if(count==300)
{
a=GetAngleToPlayer+2;
loop(36)
{
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a+20, 100);
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a-20, 106);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a+10, 120);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a-10, 126);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a+20, 100);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a-20, 106);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a+10, 120);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a-10, 126);
a+=10;
}
}
if(count==350)
{
frame=1;
}
if(count==402)
{
     frame=0;
}
if(count==500)
{
a=GetAngleToPlayer+2;
loop(36)
{
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a+20, 100);
Bullet(GetX+100*cos(a), GetY+100*sin(a), 1.8, a-20, 106);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a+10, 120);
Bullet(GetX+80*cos(a), GetY+80*sin(a), 1.4, a-10, 126);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a+20, 100);
Bullet(GetX+40*cos(a), GetY+40*sin(a), 1.8, a-20, 106);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a+10, 120);
Bullet(GetX+60*cos(a), GetY+60*sin(a), 1.4, a-10, 126);
a+=10;
}
}
if(count==550)
{
frame=1;
}
if(count==552)
{
     frame=0;
}
yield;
count++;
   }
   @Finalize
   {
      DeleteGraphic(imgEnemy);
   }
   
   @DrawLoop
   {
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetTexture(imgEnemy);
            SetGraphicRect(0, 0, 40, 40);
            DrawGraphic(GetX,GetY+z);
     if(z==10){w=-0.5;}
     if(z==-10){w=0.5;}
z+=w;
	DrawText("War'", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

   task Bullet(x, y, v, angle, graphic) {
     let obj_id=Obj_Create(OBJ_SHOT);

     Obj_SetPosition(obj_id, x, y);
     Obj_SetAngle(obj_id, angle);
     Obj_SetSpeed(obj_id, 0);
     ObjShot_SetGraphic(obj_id, graphic);
     ObjShot_SetDelay  (obj_id, 10);
     while(Obj_BeDeleted(obj_id)==false) {
	if(frame==1)
{
     Obj_SetAngle(obj_id, angle+180);
     ObjShot_SetGraphic(obj_id, graphic+10);
     Obj_SetSpeed(obj_id, v);
}
             yield;
      }
}

}
