#東方弾幕風
#Title[「十進法の廃止」]
#Text[ラストスペル：人類は十進法を廃止しました・・・。]

#BackGround[Default]
#BGM[.\BGM\x_fear]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	let count=-300;
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";	
        let eco00=GetCurrentScriptDirectory~"SE\eco00.wav";
	let imgLittle=GetCurrentScriptDirectory~"img\RumiaCutIn.png";
        let flame=-900;
        let shot1=GetCurrentScriptDirectory~"SE\shot1.wav";
        let bom36=GetCurrentScriptDirectory~"SE\bom36.wav";
        let x_fear=GetCurrentScriptDirectory~"BGM\x_fear.mp3";
        let kurokiyo=GetCurrentScriptDirectory~"BGM\kurokiyo.mp3";
	let imgback04_06=GetCurrentScriptDirectory~"img\back04_06.png";
	let imgLuna=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	let imgeffect_magic=GetCurrentScriptDirectory~"img\effect_magic.png";
	let imgAngle=0;

        @Initialize
	{

		SetLife(1200);//ライフを500に設定
		SetDamageRate(10,2);//披ダメージを10%に設定
		SetTimer(150);//時間制限を60秒に設定
                SetDurableSpellCard();//耐久スペカにします
		SetGraphicRect(1,1,64,64);//描画元矩形を設定		
		LoadGraphic(imgExRumia);//画像「img\ExRumia.png」を読みこむ
		LoadGraphic(imgLuna);
		LoadGraphic(imgeffect_magic); 		
                LoadSE(eco00);
                FadeOutMusic(x_fear,8);
                LoadMusic(kurokiyo);
                SetMovePosition03(GetCenterX,GetCenterY-115,30,5);

	}
	
	@MainLoop
	{
          if(flame== -200)
                 {
                  PlayMusic(kurokiyo);
		  CutIn(YOUMU,"「十進法の廃止」",imgLittle,1,1,350,525);//スペルカード名表示
		  SetScore(30000);//スペルカードボーナスを30000に設定
                 }


       
         if(count==600){count = 0;}

         if(flame>0)
           {  

             if(count==240)
		{
                        let j=0;
                        let h=3;
                        while(h>0)
                            {
                               loop(18) {                               
				         CreateShot02(GetX,GetY,h,GetAngleToPlayer+j,0.03,8,RED03,50);//弾を発射
                                           
                                         j+=20;
                                        }
                               h-=0.3;
                             }
                }
	    }

         if(flame>0)
           {  

             if(count==360)
		{
                        let j=0;
                        let h=rand(0,360);
                               loop(85) {                               
				         CreateShot02(GetX,GetY,5,j+h,-0.05,3,AQUA02,0);//弾を発射
                                          
                                         j+=17;
                                        }
                             
                }
	    }

         if(flame>0)
           {  

             if(count==340)
		{
                        let j=0;
                        let h=rand(0,360);

                               loop(85) {                               
				         CreateShot02(GetX,GetY,5,j+h,-0.07,1,WHITE04,0);//弾を発射
                                         
                                         j+=17;
                                        }
                             
                }
	    }
       
        if(flame >0) 
         {
           if(count==400)
              {
                 let j=rand(0,360);
                 let dimasama=0;
                 let misyakujisama=0;
                 let i=0;
            
                  loop(36)
                   {
                    CreateShotA(dimasama,GetX,GetY,20);
                    SetShotDataA(dimasama,0,8,i+j,1.2,-0.3,1,PURPLE12);
                    SetShotDataA(dimasama,100,NULL,NULL,0.15,0,1,PURPLE12);
                    FireShot(dimasama);


                    CreateShotA(misyakujisama,GetX,GetY,20);
                    SetShotDataA(misyakujisama,0,8,i+j,-1.2,-0.3,1,PURPLE12);
                    SetShotDataA(misyakujisama,100,NULL,NULL,-0.15,0,1,PURPLE12);
                    FireShot(misyakujisama);
                    i+=10;
                   }
               }
           if(count==450)
              {
                 let j=rand(0,360);
                 let dimasama=0;
                 let misyakujisama=0;
                 let i=0;
            
                  loop(36)
                   {
                    CreateShotA(dimasama,GetX,GetY,20);
                    SetShotDataA(dimasama,0,8,i+j,1.2,-0.3,1,PURPLE12);
                    SetShotDataA(dimasama,100,NULL,NULL,0.15,0,1,PURPLE12);
                    FireShot(dimasama);


                    CreateShotA(misyakujisama,GetX,GetY,20);
                    SetShotDataA(misyakujisama,0,8,i+j,-1.2,-0.3,1,PURPLE12);
                    SetShotDataA(misyakujisama,100,NULL,NULL,-0.15,0,1,PURPLE12);
                    FireShot(misyakujisama);
                    i+=10;
                   }
               }
         }

         if(flame>1200)
           {  

             if(count<36&&count%3==0)
		{
                               let radius=80;
                               let angle=0;
                               loop(10) {
                                        let g = GetX + offsetX(radius, angle);
                                        let t = GetY + offsetY(radius, angle);                                
				         CreateShot02(g,t,4,angle+count*0.8,-0.2,1.5,BLUE23,50);//弾を発射
                                         angle+=36;                                      
                                        }

                }
	    }

         if(flame>660)
           {  

             if(count>540&&count%4==0)
		{
                               let h=60;
                               loop(10) {                               
				         CreateShot02(GetX,GetY,6,h-count*0.25,-0.2,1.5,RED21,0);//弾を発射
                                         h+=36;                                       
                                        }

                }
	    }
         if(flame>1200)
           {
                if(count>440&&count%20==2)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 30;
                            loop(15) {
                                     CreateShot01(GetX, GetY, j, angle, GREEN22, 0);
                                     angle += 24;
                                     }
                            j-=1
                        }
                 }
            }

         if(flame>1800)
              {
                if(count>440&&count%20==2)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 90;
                            loop(4) {
                                     CreateLaser01(GetX, GetY,j+1, angle,90, 15, GREEN01, 0);
                                     CreateLaser01(GetX, GetY,j, 45-angle,50, 5, GREEN01, 0);
                                     angle += 90;
                                     }
                            j-=1
                        }
                 }
               }
         if(flame>1200)
              {
		if(count==520)		
                {
                        let j=3;
                        while(j>1)
                        {
                            let angle = 90;
                            loop(90) {
                                     CreateShot01(GetX, GetY, j, angle, ORANGE05, 0);
                                     angle += 4;
                                     }
                            j-=1
                        }
                 }                               
               }

         

         if(flame>2400)
               {
		           if(count==0)		
                                        {
                                          let j=5;
                                          while(j>1)
                                              {
                                               let radius = 100;
                                               let angle = 90;
                                               loop(90) {
                                                         let g = GetX + offsetX(radius, angle);
                                                         let t = GetY + offsetY(radius, angle);
                                                         CreateLaser01(g, t, j, angle, 70,4,YELLOW05, 30);
                                                         angle += 8;
                                                         }
                                               j-=1
                                               }
                                         }
                 }

        if(flame==7200){PlaySE(bom36);
			PlaySE(shot1);}
        if(flame>7200)
               {
                 let f=rand(0,360);
                 CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/40,f,-0.1,1.5,PURPLE01, 5);
                }


        if(GetEnemyLife<210&&count==100){PlaySE(bom36);
					PlaySE(shot1);}
        if(GetEnemyLife<180)
               {
                 let f=rand(0,360);
                 CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/40,f,-0.1,1.5,PURPLE01, 5);
                }
 
       if(GetEnemyLife<40)
               {
                Slow(2);
                MotionBlurEx(ALL,50,100,ALPHA);
                let f=rand(0,360);
                CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/20,f,-0.1,3,WHITE02, 5);
               }
       if(GetEnemyLife<50&&flame%20==1){PlaySE(bom36);}

                function offsetX(radius, angle) {
                return radius * cos(angle);
                }

                function offsetY(radius, angle) {
                return radius * sin(angle);
                }


                if(flame==0)
                      {                     
                       Concentration01(100);
                       Concentration02(200);
                      }
 		if(flame==150){PlaySE(eco00);}
                if(flame==800){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==1400){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==2000){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==2600){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8700){Slow(2);}
                if(flame==8700){
                                PlaySE(bom36);
				PlaySE(shot1);
                                MotionBlurEx(ALL,320,100,ALPHA);
                                let f=rand(0,360);
                                CreateShot02(GetX-12+f/15,GetY-12+f/15,1+f/20,f,-0.1,3,WHITE02, 5);
                                }
                if(flame==8910){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8940){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8970){PlaySE(bom36);
				PlaySE(shot1);}
                if(flame==8999){PlaySE(bom36);
				PlaySE(shot1);}

           if(flame>300)
               {
		SetCollisionA(GetX(),GetY(),32);//当たり判定(自弾)登録
		SetCollisionB(GetX(),GetY(),24);//当たり判定(体当たり)登録
               }
		count++;
                flame++;
	}
	
	@Finalize
	{//読みこんだファイルを削除
          PlaySE(bom36);
          PlaySE(shot1);
	  Explosion01(GetX,GetY,3,5,120);
          DeleteGraphic(imgExRumia);  
                
          loop(100)
              {
	       CreateItem(ITEM_SCORE,GetX+rand(-100,100),GetY+rand(20,100));
               }
         CollectItems();
         
               
	}
	
	@DrawLoop
	{
		//Exルーミア描画
	 if(flame>300)
               {	
                SetGraphicRect(64,1,127,64);                             
		SetAlpha(255);
		SetTexture(imgExRumia);
		DrawGraphic(GetX(),GetY());
	       }
		if(flame>300)
			{

			SetGraphicRect(0,80,150,230);
			SetAlpha(255);
			SetGraphicAngle(0,0,-imgAngle);
			SetTexture(imgeffect_magic);
			DrawGraphic(GetX(),GetY());
			imgAngle+=0.5;
			}

		if(flame>300)
			{

			SetGraphicRect(300,230,450,380);
			SetAlpha(255);
			SetGraphicAngle(0,0,imgAngle);
			SetTexture(imgeffect_magic);
			DrawGraphic(GetX(),GetY());
			imgAngle+=0.5;
			}

                              
	}

	@BackGround
	{
	//スペルカード時の背景部分
	//無くてもよい


		SetTexture(imgLuna);
		SetGraphicRect(1,1,384,448);
		SetAlpha(255);
		SetGraphicAngle(0,0,0);
		DrawGraphic(GetCenterX,GetCenterY);
				
	}


    function offsetX(radius, angle) {
        return radius * cos(angle);
    }

    function offsetY(radius, angle) {
        return radius * sin(angle);
    }

}


