#TouhouDanmakufu
#Title[Maritin : "Star system"]
#Text[Maritin est decide a eliminer tous les monstres qui envahissent MU. Pour se proteger il se cache dans son oeuf, mais il ne reconnait plus ses allies de ses ennemis... Ici, il invoque deux petits allies qui jouent respectivement le role de la Lune et du Soleil. Cette attaque est particulierement dangereuse, faites attention.]
#Image[]
#BGM[script\DanMUku\Stage3\Stage3.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\Stage3\Image\Maritin.png";
    let bg = "script\DanMUku\Stage1\Image\etoiles.png";
    let count = -120;
    let t = 0;
    let a = 0;
    let angle = 0;
    let tir ="script\DanMUku\Stage1\Son\tir.wav";
    let munch ="script\DanMUku\Stage1\Son\muncher.wav";
     let q =0;
    let bonus=true;

   @Initialize
   {
            LoadUserShotData("script\DanMUku\MUtir\MUtir.txt");
            LoadGraphic(imgEnemy);
            LoadGraphic(bg);
            SetLife(3000);
            SetTimer(60);
            SetInvincibility(100);
            SetEnemyMarker(true);
            SetMovePosition02(GetCenterX, GetCenterY-100, 120);       
            SetScore(1300000); 
            CutIn(YOUMU, "Star system", "" , 0,0,0,0);       
   }
   
   @MainLoop
   {
        SetCollisionA(GetX, GetY, 16);
        SetCollisionB(GetX, GetY, 16);
	if(GetTimer==35){
		bonus=false;
	}

if(count==0)
{
CreateEnemyFromScript("lune", GetX, GetY, 0, 0, 0);
}
if(count>=0)
{
	SetSpeed(3);
	SetAngle(a);
	a+=2;
}
if(count%3==0&&count>0)
{
if(count%4==0)
{
PlaySE(tir);
}
CreateShot01(GetX, GetY, 1.5, t, 20, 0);
}
if(count%80==0&&count>100)
{
PlaySE(munch);
angle=GetAngleToPlayer;
loop(18){
CreateShot01(GetCenterX, GetCenterY, 0.8, angle, 86, 130);
angle+=20;
}
}
count++;
t+=10;
yield;
   }
   @Finalize
   {
      DeleteGraphic(imgEnemy);
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20));  
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20));  
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20));  
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20));  
CreateItem(ITEM_SCORE, rand(GetX-20, GetX+20), rand(GetY-20, GetY+20)); 
	if(bonus){
		SetCommonData("B", true);
	}
   }
   
   @DrawLoop
   {
            SetTexture(bg);
            SetRenderState(ALPHA);
            SetAlpha(255);
            SetGraphicRect(0, 0, 50000+q, 50000+q);
            SetGraphicScale(1,1);
            SetGraphicAngle(0, 0, 0);
            DrawGraphic(GetCenterX+q, GetCenterY+q);

            SetTexture(imgEnemy);
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetGraphicAngle (0, 0, t);
            SetGraphicRect(0, 0, 28, 35);
            DrawGraphic(GetX,GetY);

	q-=2;
   }

}


script_enemy lune {

    let imgEnemy ="script\DanMUku\Stage3\Image\Maritin.png";
    let t = 0;
    let count = 0;
    let a = 0;

@Initialize{
    LoadUserShotData("lib\MUtir\MUtir.txt");
    SetLife(10);
    LoadGraphic(imgEnemy);

 }
@MainLoop{
        SetCollisionA(GetX, GetY, 8);
        SetCollisionB(GetX, GetY, 8);
         SetDamageRateEx(0,0,50,50);
if(count%3==0)
{
CreateShot01(GetX, GetY, 1.5, t, 15, 0);
}
SetMovePosition02(GetEnemyX+40*cos(a), GetEnemyY+40*sin(a), 2);
a+=3.5;
t+=3;
count++;
yield;
 }
@DrawLoop{
            SetColor(255,255,255);
            SetRenderState(ALPHA);
            SetTexture(imgEnemy);
            SetGraphicAngle (0, 0, -t);
            SetGraphicRect(0, 0, 28, 35);
            SetGraphicScale(0.5, 0.5);
            DrawGraphic(GetX,GetY);
	DrawText("Maritin", GetClipMinX+10, GetClipMinY+15, 12, 255);

 }
@Finalize{
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  
CreateItem(ITEM_SCORE, rand(GetX-10, GetX+10), rand(GetY-10, GetY+10));  


     DeleteGraphic(imgEnemy);
 }
}
