#TouhouDanmakufu
#Title[Noob Man : "Hatter sign : Top destruction"]
#Text[Noob Man a une sacre reserve de chapeaux tout moche. Il en sort des projectiles a la place des lapins. Vous pouvez detruire les chapeaux pour les empecher d'envoyer plus de projectiles. Vous pouvez aussi essayer de terminer cette attaque sans tirer mais vous aurez besoin de beaucoup de talents.]
#Image[]
#BGM[script\DanMUku\Stage6\NoobMan.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\Stage6\Image\noobman.png";
    let count=-100;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
    let bg = "script\DanMUku\Stage6\Image\fondchapeau.png";
    let x = GetX;
    let q = 0;


 function Wait(let frames){
   loop(frames){yield;}
 }


   @Initialize
   {
      LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
      LoadGraphic(imgEnemy);
	LoadGraphic(bg);
      LoadSE(tir);
      LoadSE(munch);
            SetLife(5000);
            SetTimer(50);
            SetInvincibility(100);
	SetScore(1000000);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100 , 60);
	CutIn(YOUMU, "Hatter sign"\""Top destruction"\", "script\DanMUku\Stage6\Image\noobcutin.png" , 0,0,121,214);
   }
   
   @MainLoop
   {
          SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
	SetDamageRate(100,50);

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

	if (count%600==100) {
		PlaySE(tir);
		ascent (i in 0..7) {
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, GetAngleToPlayer-40+i*20, [0, 85]);
		}
	}

	if (count%600==300) {
		PlaySE(tir);
		ascent (i in 0..7) {
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, 180+GetAngleToPlayer-40+i*20, [0,87]);
		}
	}

	if (count%600==500) {
		PlaySE(tir);
		ascent (i in 0..10) {
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, i*36, [0,90]);
		}
	}


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

	loop(9) {
		CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
	}
   }
   

   @DrawLoop
   {

	    SetTexture(bg);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 50000+q, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            SetColor(5,155,155);
            DrawGraphic(GetCenterX+q, GetCenterY+q);
	q++;

	if(x<GetX){
		SetGraphicAngle(0,0,0);
	}
	if(x>GetX){
		SetGraphicAngle(180,0,0);
	}
      x=GetX;
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
	if (GetSpeed>0) {	
	            SetGraphicRect(28,0,55,34);
	}
	else {
		    SetGraphicRect(0,0,27,34);
	}

            DrawGraphic(GetX,GetY);

	DrawText("Noob Man", GetClipMinX+10, GetClipMinY+15, 12, 255);

	//let i = 0;
	//loop(length(string)) {
	//	DrawText(string[i], GetClipMinX+10, GetClipMinY+35+20*i, 12, 255);
	//	i++;
	//}
   }





}
