#TouhouDanmakufu
#Title[Full_Korbe : "Blue and White : Shower of cards"]
#Text[Un deck pre-construit et jouable contenant 40 cartes. Piochez, piochez et piochez a volonte ! Et grace a votre main, amassez les pieces et decouragez les attaques de votre adversaire avec ce deck bleu / blanc ! Ici, essayez de suivre Fully, mieux vaut ne pas se trouver au milieu de toutes ces cartes bleues !]
#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 x = GetClipMinX;
	let a = 60;
    let q=0;
    let spin =0;

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

	if (count%220==0){
		a=210-a;
		x=GetClipMaxX+GetClipMinX-x;
		SetMovePositionRandom01(rand(50,300), rand(50,100), 2, GetCenterX+(a-105)/2, GetClipMinY+10, x-(a-105)/2, GetCenterY);
	}

	if (count%220>10&&count%220<120&&count%6==0){
		let y = 0;
		loop(6){
			Carte_Blanche(x, y, 2.5, a, 0);
			y+=70;
		}
	}

	if (count%220>10&&count%220<80&&count%12==0){
		let X=GetClipMaxX+GetClipMinX-x;
		loop(8) {
			Carte_Bleue(X, GetClipMinY, rand(4,9), 90, 0 );
			X+=(a-105)/rand(0.9,3.5);
		}
		PlaySE(tir);
	}


	yield;
	count++;
   }
   @Finalize
   {
      DeleteGraphic(imgEnemy);
   }
   
   @DrawLoop
   {
	SetColor(0,0,255);
	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);
            SetTexture(imgEnemy);
	    SetGraphicAngle(0, 0, 0);
	    SetGraphicScale(1,1);
            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_Bleue(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, 142);
            ObjShot_SetDelay  (obj, delay);
		let count = 0;
		let dir = 0;
		let phase = 1;
		let count = 0;
		let alea = rand_int(130,200);

		if (angle%360>270||(angle%360>90&&angle%360<180)) {
			dir=5;
		}
		else {
			dir=-5;
		}

	while(Obj_BeDeleted(obj)==false)
      {
	if (phase==1){
		Obj_SetSpeed(obj, Obj_GetSpeed(obj)-v/100);
		if (count==100) {
			phase = 2;
		}
	}

	if (phase==2){
		Obj_SetAngle(obj, Obj_GetAngle(obj)+dir);
		if ( count==alea ) {
			phase = 3;
		}
	}

	if (phase==3){
		Obj_SetSpeed(obj, Obj_GetSpeed(obj)+0.03);
	}

	count++;
	yield;
      }

   }

}
