#TouhouDanmakufu
#Title[Full_Korbe : "Red and Purple : Heat of the action"]
#Text[Un deck pre-construit et jouable contenant 40 cartes. Votre adversaire sera coince en voyant chacun de ses Personnages se faire calciner par ce deck rouge / violet ! Pour cette attaque, tentez de monter quand les cartes descendent puis de redescendre apres, vous n'aurez qu'a esquiver une vague de projectiles a la fois.]
#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 a=0;
    let q=0;
    let spin =0;

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

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

	if (count%600>400&&count>0&&count%15==0){
		PlaySE(tir);
		loop(3){
			let v=3;
			loop(8){
				Carte_Rouge(GetX, GetY, v, a, 0);
				v+=0.5;
			}
			a+=4;
		}
		a+=16;
	}

	if (count%600<350&&count>0&&count%30==10){
		let xx = GetClipMinX;
		loop(10){
			Carte_Violette(xx, GetClipMinY, 2, rand(70, 110), 5);
			xx+=rand(30,45);
		}
	}

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

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

	SetColor(100,0,200);
	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_Rouge(x, y, v, angle, delay)
   {
	CreateShot02(x, y, 0, angle, 0.05, v, 140, delay);
   }

   task Carte_Violette(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, 141);
            ObjShot_SetDelay  (obj, delay);
	    ObjShot_SetBombResist(obj, true);
      let counter=0;

            while(Obj_BeDeleted(obj)==false)
      {
                    if(Obj_GetY(obj)>GetClipMaxY&&counter==0)
         {
	        Obj_SetAngle(obj, rand(190, 350) );
		Obj_SetSpeed(obj, v/2);
                          Obj_SetY(obj,  Obj_GetY(obj) + 0.1);
	        ObjShot_SetGraphic(obj, 137);
            counter++;
                    }

         yield;
            }
   }

}
