#TouhouDanmakufu
#Title[Full_Korbe : "Green and Yellow : Tall grass"]
#Text[Un deck pre-construit et jouable contenant 40 cartes. L'union fait la force ! Vous aurez toujours des troupes fraiches pour submerger votre adversaire dans ce deck vert / jaune ! Il n'y a pas beaucoup plus de cartes dans cette attaque que dans les autres mais les cartes vertes vous forceront a rester en mouvement.]
#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 epee ="script\DanMUku\Stage5\Son\epee.wav";
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let z = 0;
    let w = 0.5;
    let x=0;
    let y=0;
    let angle=0;
    let q=0;
    let spin =0;

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

	if (count%100==0&&count>=0){
		let angle=rand(0,360);
		x = GetX+cos(angle)*200;
		y = GetY+sin(angle)*200;
		while(x<GetClipMinX+10 || x>GetClipMaxX-10 || y<GetClipMinY+10 ||y>GetClipMaxY-200) {
			angle=rand(0,360);
			x = GetX+cos(angle)*200;
			y = GetY+sin(angle)*200;
		}
		CreateLaserA(1, GetX, GetY, 200, 30, 1, 60);
		SetLaserDataA(1, 0, angle, 0, 0, 0, 0);
		SetShotKillTime(1, 59);
		FireShot(1);
		Concentration01(60);
	}

	if (count%100<60&&count%20==0&&count>0){
		let delay=0;
		PlaySE(tir);
		loop(10){
			Carte_Jaune(GetX, GetY, 2, angle, delay);
			delay+=3;
			angle+=360/11;
		}
	}

	if (count%100==60&&count>0){
		SetMovePosition02(x, y, 10);
		PlaySE(epee);
	}

	if (count%100>60&&count%100<70&&count>0){
		SetShotDirectionType(SEQUENCE);
		Carte_Verte(GetX, GetY, 3, rand(30,150), 0);
		Carte_Verte(GetX, GetY, 3, rand(210, 330), 0);
		SetShotDirectionType(ABSOLUTE);
	}


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

	SetColor(0,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,0);
	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_Verte(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, 143);
            ObjShot_SetDelay  (obj, delay);
		let count = 0;

	while(Obj_BeDeleted(obj)==false)
      {
	if (count<100) {
		Obj_SetSpeed(obj, Obj_GetSpeed(obj)-v/100);
	}	
	if (count==100) {
		Obj_SetAngle(obj, atan2(GetPlayerY-Obj_GetY(obj), GetPlayerX-Obj_GetX(obj)));
		Obj_SetSpeed(obj, v);
	}

	count++;
	yield;
      }

   }

   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;
            }
   }

}
