#TouhouDanmakufu
#Title[Full_Korbe : "Star sign : Cut"]
#Text[L'epee de Full_Korbe, le nombre de choses qu'elle ne peut pas couper est proche de zero ! En tout cas, il peut couper ses etoiles et vous alors eloignez-vous de lui avant qu'il ne fonce sur vous. Le timing s'accelere au fur et a mesure, faites attention !]
#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\Stage1\Image\etoiles.png";
    let count=-200;
    let epee ="script\DanMUku\Stage5\Son\epee.wav";
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch = "script\DanMUku\Stage1\Son\munch.wav";
    let z = 0;
    let w = 0.5;
    let x=0;
    let y=0;
    let rythme=250;
    let q=0;
    let coupe=false;
    let shota1=0;
    let shota2=0;

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
	    LoadGraphic(bg);
	    LoadSE(munch);
	    LoadSE(epee);
            SetLife(4000);
            SetTimer(60);
	    SetScore(1000000);
            SetInvincibility(160);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120);  
	    CutIn(YOUMU, "Star sign"\""Cut"\", "script\DanMUku\Stage5\Image\fullycutin.png" , 0,0,99,200);      
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);

	if (count%rythme==0&&count>=0){
		x=GetPlayerX;
		y=GetPlayerY;
		CreateLaserA(1, GetX, GetY, ( absolute(GetX-GetPlayerX)^2 + absolute(GetY-GetPlayerY)^2 )^(0.5), 30, 1, 100);
		SetLaserDataA(1, 0, GetAngleToPlayer, 0, 0, 0, 0);
		SetShotKillTime(1, 99);
		FireShot(1);
		Concentration01(100);
	}

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

	if (count%rythme==110&&count>0){
		coupe=false;
		rythme-=4;
	}

	if(count>0&&count%12==0){
		PlaySE(munch);
		Etoile(GetPlayerX+cos(shota1)*60, GetPlayerY+sin(shota1)*60, 2.5, shota1, 0.1, 10, 53);
		Etoile(GetPlayerX+cos(shota1+120)*60, GetPlayerY+sin(shota1+120)*60, 2.5, shota1+120, 0.1, 10, 54);
		Etoile(GetPlayerX+cos(shota1-120)*60, GetPlayerY+sin(shota1-120)*60, 2.5, shota1-120, 0.1, 10, 57);
		shota1+=5;
	}

	if(count>0&&count%12==4){
		PlaySE(munch);
		Etoile(GetPlayerX+cos(shota2)*60, GetPlayerY+sin(shota2)*60, 2.5, shota2, -0.1, 10, 55);
		Etoile(GetPlayerX+cos(shota2+120)*60, GetPlayerY+sin(shota2+120)*60, 2.5, shota2+120, -0.1, 10, 56);
		Etoile(GetPlayerX+cos(shota2-120)*60, GetPlayerY+sin(shota2-120)*60, 2.5, shota2-120, -0.1, 10, 58);
		shota2-=5;
	}	


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

	SetColor(255,255,255);
	SetRenderState(ALPHA);
            SetAlpha(255);
            SetTexture(bg);
	    SetGraphicAngle(0, 0, 0);
            SetGraphicRect(q, -q, 2900+q, 2170-q);
            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;
q+=1;
	DrawText("Full_Korbe", GetClipMinX+10, GetClipMinY+15, 12, 255);
   }

   task Etoile(x, y, v, angle, angspeed, delay, g)
   {

	    let petite = [38, 43, 40, 45, 48, 50][g-53];
            let obj=Obj_Create(OBJ_SHOT);

            Obj_SetPosition(obj, x, y);
            Obj_SetAngle(obj, angle);
            Obj_SetSpeed(obj, v);
            ObjShot_SetGraphic(obj, g);
            ObjShot_SetDelay  (obj, delay);
	
	while(Obj_BeDeleted(obj)==false)
      {
	if(coupe==true && absolute(GetX-Obj_GetX(obj))<50 && absolute(GetY-Obj_GetY(obj))<50 ){
		let a = rand(0,360);
		loop(4){
			CreateShot01(Obj_GetX(obj), Obj_GetY(obj), v, a, petite, 0);
			a+=90;
		}
		a+=rand(0,60);
		loop(6){
			CreateShot01(Obj_GetX(obj), Obj_GetY(obj), 0.5, a, petite, 0);
			a+=60;
		}
		Obj_Delete(obj);
	}

	Obj_SetAngle(obj, Obj_GetAngle(obj)+angspeed);

	yield;
	}

   }



}
