#TouhouDanmakufu
#Title[Full_Korbe : "Yellow and White : Right through the heart"]
#Text[Un deck pre-construit et jouable contenant 40 cartes. Regenerez-vous pour epuiser petit a petit votre adversaire avec ce deck base sur des cartes jaunes et blanches ! Ce deck construit par Full_Korbe est redoutable ! Les vagues de cartes blanches bougent toujours de maniere inattendue.]
#Image[]
#BGM[script\DanMUku\Stage5\fully.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\Stage5\Image\fully.png";
    let bg = "script\DanMUku\Stage5\Image\abstrait.png";
    let fg = "script\DanMUku\Stage5\Image\rond.png";
    let count=-60;
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let z = 0;
    let w = 0.5;
    let q=0;
    let spin =0;

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
	    LoadGraphic(fg);
	    LoadSE(tir);
	    LoadSE(munch);
            SetLife(4000);
            SetTimer(40);
	    SetScore(1300000);
            SetInvincibility(160);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120);  
	    CutIn(YOUMU, "Yellow and White"\""Right through the heart"\", "script\DanMUku\Stage5\Image\fullycutin.png" , 0,0,99,200);      
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);

	if (count%100==0){
		SetMovePositionRandom01(rand(50,200), rand(50,100), 2, GetClipMinX+10, GetClipMinY+10, GetClipMaxX-10, GetCenterY);
		Concentration01(30);
	}

	if (count%100>10&&count%100<30){
		let delay=0;
		let a=count*13;
		loop(4){
			Carte_Jaune(GetX, GetY, 3, a, delay);
			delay+=3;
		}
		PlaySE(tir);
	}

	if (count%100==40){
		let delay=0;
		let a=GetAngleToPlayer;
		loop(9){
			loop(18){
				Carte_Blanche(GetX, GetY, 2, a, delay);
				a+=360/18;
			}
			delay+=5;
			a+=2;
		}
		PlaySE(munch);
	}

	yield;
	count++;
   }
   @Finalize
   {
      DeleteGraphic(imgEnemy);
   }
   
   @DrawLoop
   {

	SetColor(255,255,0);
	SetRenderState(ALPHA);
            SetAlpha(255);
            SetTexture(bg);
	    SetGraphicAngle(0, 0, 0);
            SetGraphicRect(q, q, 640+q, 480+q);
            DrawGraphic(GetCenterX,GetCenterY);

	SetColor(255,255,255);
	SetRenderState(ALPHA);
            SetAlpha(100);
            SetTexture(fg);
	    SetGraphicAngle(0, 0, spin);
            SetGraphicRect(0, 0, 544, 416);
	    SetGraphicScale(2,2);
            DrawGraphic(GetCenterX,GetCenterY);

            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetAlpha(255);
	    SetGraphicAngle(0, 0, 0);
	    SetGraphicScale(1,1);
            SetTexture(imgEnemy);
            SetGraphicRect(0, 0, 35, 46);
            DrawGraphic(GetX,GetY+z);
     if(z==10){w=-0.5;}
     if(z==-10){w=0.5;}
z+=w;
spin-=0.5;
q-=1;
	DrawText("Full_Korbe", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

   task Carte_Blanche(x, y, v, angle, delay)
   {
	CreateShotA(1, x, y, delay);
	SetShotDataA(1, 0, v, angle, -1, 0, v, 146);
	SetShotDataA(1, 60, NULL, NULL, 1, 0, v, 146);
	SetShotDataA(1, 120, NULL, NULL, -1, 0, v, 146);
	SetShotDataA(1, 180, NULL, NULL, 1, 0, v, 146);
	SetShotDataA(1, 240, NULL, NULL, -1, 0, v, 146);
	FireShot(1);
   }

   task Carte_Jaune(x, y, v, angle, delay)
   {
            let obj=Obj_Create(OBJ_SHOT);

            Obj_SetPosition(obj, x, y);
            Obj_SetAngle(obj, angle);
            Obj_SetSpeed(obj, v);
            ObjShot_SetGraphic(obj, 144);
            ObjShot_SetDelay  (obj, delay);
      let counter=0;

            while(Obj_BeDeleted(obj)==false)
      {
                    if(Obj_GetX(obj)<GetClipMinX&&counter==0)
         {
                          Obj_SetAngle(obj,  180-Obj_GetAngle(obj) );
                          Obj_SetX(obj,  Obj_GetX(obj) + 0.1);
	        ObjShot_SetGraphic(obj, 50);
            counter++;
                    }

                    if(Obj_GetX(obj)>GetClipMaxX&&counter==0)
         {
                          Obj_SetAngle(obj,  180-Obj_GetAngle(obj) );

                          Obj_SetX(obj,  Obj_GetX(obj) - 0.1);
	        ObjShot_SetGraphic(obj, 50);
            counter++;
                    }

                    if(Obj_GetY(obj)<GetClipMinY&&counter==0)
         {
	        Obj_SetAngle(obj, -Obj_GetAngle(obj) );
                          Obj_SetY(obj,  Obj_GetY(obj) + 0.1);
	        ObjShot_SetGraphic(obj, 50);
            counter++;
                    }

         yield;
            }
   }

}
