#TouhouDanmakufu
#Title[Noob Man : "Hatter sign : Swirling hats"]
#Text[Noob Man fait a nouveau appel a ses chapeaux mais cette fois, ils, et les tirs qu'ils projettent, ont des trajectoires plus incurvees. Noob Man deteste vraiment les pacifistes...]
#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(3000);
            SetTimer(60);
            SetInvincibility(120);
	SetScore(1200000);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100 , 60);
	CutIn(YOUMU, "Hatter sign"\""Swirling hats"\", "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-80);
	}

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

	if (count%600==200) {
		PlaySE(tir);
		ascent (i in 0..6) {
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, GetAngleToPlayer-i*20, [1,82]);
		}
	}

	if (count%600==500) {
		PlaySE(tir);
		ascent (i in 0..4) {
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, i*90, [1,90]);
			CreateEnemyFromFile("script\DanMUku\Stage6\Chapeau.txt", GetX, GetY, 2, i*90, [-1,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(150,55,5);
            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++;
	//}
   }





}
