#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
	#include_function ".\lib\lib_anime_Sunnymilk.txt"
	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_sunnymilk.png";
        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
	let bounus=5000000;		//スペル基本得点

    	@Initialize
        {
	  SetLife(1000);
	  SetDamageRate(0,0);
	  SetCountDown;
	  SetMovePosition02(cx,cy-120,0);
	  let X = GetCommonData("X");//ルナの位置を継続させる
	  let Y = GetCommonData("Y");
	  let X2 = GetCommonData("X2");//スターの位置を継続させる
	  let Y2 = GetCommonData("Y2");
	  CreateEnemyFromScript("Luna",X,Y,0,0,0);//ボスパートナー
	  CreateEnemyFromScript("Ster",X2,Y2,0,0,0);//ボスパートナー
          Tmain;
	}
	
	@MainLoop
	{  
                yield;
                SetCollisionA(GetX(),GetY(),32);
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
        } 
	
	@Finalize
	{       
		loop(20){
			CreateShotFromScript("I_Item",GetX+rand(-150,150),GetY+rand(-100,100),0,0,0,1);
		}
		loop(30){
			CreateShotFromScript("TenItem",GetX+rand(120,-120),GetY+rand(80,-80),0,0,0,0);
		}

		SetCommonData("SpellCade",false);
		if(GetMissCountInThisSpell == 0 && GetBombCountInThisSpell == 0 && IsTimeOut == false){//スペル取得した時
			PlaySE("seGetSpellCardBonus.wav");			//効果音
			SetCommonData("GetSpell",true);				//スペルを取得したかどうか
		}
	}

	@DrawLoop
	{//描画
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}

        task Tmain
        {
		yield;
		//前のスペルを収得したかどうか--------------------------------------------------------------
		if(GetCommonData("GetSpell")==true){GetSpellEffect( GetCommonData("GetSpellBounus_B") );}

		loop(120){yield;}
		let IceScore = GetCommonData("GetIce");						//得点調査
		let Points=200000+GetGraze*10+IceScore+truncate(GetScore/100)-10000*GetBombCount;

		SpellCutName(256,160,bounus);		//カード名
		SetDurableSpellCard;
		SetMovePosition03(cx,cy-120,10,10);
	 	SetAction(ACT_MOVE,60);
		SetTimer(121);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		SetDamageRate(12,1);
		//弾幕-------------------------------------------------------------------------------------
		let angle = 0;
		SetCommonData("KEITAI",1);
		let ways;
		alternative(Level)
		case(1){//hard
			ways = [24,36];
		}
		case(0){//easy
			ways = [12,18];
		}
		loop{
			PlaySE(shoot13);
			loop(ways[0]){
				CreateShot01(GetX, GetY, 2, angle,114,10);
				angle += 360 / ways[0];
			}
			angle += 360 / ways[0] /3;
			loop(40){yield}
			if(GetLife<=850 || GetTimer <=50){break;}
		}
		SetCommonData("KEITAI",2);
		loop{
			PlaySE(shoot13);
			loop(ways[0]){
				CreateShot01(GetX, GetY, 3, angle,114,10);
				angle += 360 / ways[0];
			}
				angle += 360 / ways[0] /3;
			loop(40){yield}
			if(GetLife<=650 || GetTimer <=50){break;}
		}
		SetCommonData("KEITAI",3);
		loop{
			PlaySE(shoot13);
			loop(ways[0]){
				CreateShot01(GetX, GetY, 2, angle,114,10);
				angle += 360 / ways[0];
			}
			angle += 360 / ways[0] /3;
			loop(30){yield}
			if(GetLife<=380 || GetTimer <=50){break;}
		}
		SetDamageRate(10,0);
		SetCommonData("KEITAI",4);
		loop{
			PlaySE(shoot13);
			loop(ways[1]){
				CreateShot01(GetX, GetY, 1, angle,114,10);
				angle += 360 / ways[1];
			}
			angle += 360 / ways[1] /3;
			loop(20){yield}
		}

	}
}

script_enemy Luna{
        #include_function ".\lib\lib_anime_Lunachild.txt"
	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_lunachild.png";
        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
    	@Initialize
        {
	  SetLife(2000);
          SetInvincibility(90);
	  SetDamageRateEx(0,0,100,100);

          Tmain;
	}	
	@MainLoop
	{  
                yield;
                SetCollisionA(GetX(),GetY(),32);
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
        } 	
	@Finalize
	{       

	}
	@DrawLoop
	{//描画
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}       
        task Tmain
        {
		loop(90){yield;}
		SetMovePosition03(cx-100,cy-20,10,10);
	 	SetAction(ACT_MOVE,60);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		//弾幕-------------------------------------------------------------------------------------
		let angle = 0;
		let ways;
		alternative(Level)
		case(1){//hard
			ways = [3,5,9];
		}
		case(0){//easy
			ways = [1,3,5];
		}
		loop{
			PlaySE(arrow01);
			loop(ways[0]){
				CreateShot01(GetX, GetY, 2, angle, 115,10);
				angle += 30 / ways[0];
			}
			angle += 30 / ways[0] /2;
			if(GetCommonDataDefault("KEITAI",0) == 2){break;}
			loop(10){yield}
		}
		
		loop{
			PlaySE(arrow01);
			loop(ways[0]){
				CreateShot01(GetX, GetY, 3, angle,115,10);
				angle += 30 / ways[0];					
			}
			angle += 30 / ways[0] /2;
			if(GetCommonDataDefault("KEITAI",0) == 3){break;}
			loop(10){yield}
		}
		loop{
			PlaySE(arrow01);
			loop(ways[1]){
				CreateShot01(GetX, GetY, 2, angle,115,10);
				angle += 30 / ways[1];					
			}
			angle += 50 / ways[1] /2;
			if(GetCommonDataDefault("KEITAI",0) == 4){break;}
			loop(10){yield}
		}
		loop{
			loop(ways[2]){
				CreateShot01(GetX, GetY, 1, angle,115,10);
				angle += 40 / ways[2];					
			}
			angle += 100 / ways[2] /2;
			loop(10){yield}
		}
	}
}

script_enemy Ster{
        #include_function ".\lib\lib_anime_Starsapphire.txt";
	let imgBoss = GetCurrentScriptDirectory~"img\Boss\dot_starsapphire.png";

        #include_function ".\lib\lib_Bosscommon.txt"
        #include_function ".\lib\lib_SpellBouns.txt"
    	@Initialize
        {
	  SetLife(2000);
          SetInvincibility(90);
	  SetDamageRateEx(0,0,100,100);

          Tmain;
	}
	@MainLoop
	{  
                yield;
                SetCollisionA(GetX(),GetY(),32);
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
        } 
	@Finalize
	{       

	}
	@DrawLoop
	{//描画
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}       
        task Tmain
        {
		loop(90){yield;}
		SetMovePosition03(cx+100,cy-20,10,10);
	 	SetAction(ACT_MOVE,60);
		loop(60){yield;}
		SetAction(ACT_SPELL,60);
		loop(60){yield;}
		//弾幕-------------------------------------------------------------------------------------
		let angle = 0;
		let N_angle = 0;
		let ways;
		alternative(Level)
		case(1){//hard
			ways = [3,5,9];
		}
		case(0){//easy
			ways = [1,3,5];
		}
		loop{
			N_angle = angle;
			loop(ways[0]){
				CreateShot01(GetX, GetY, 2, angle ,117,10);
				angle += 30 / ways[0];
			}
			angle = N_angle + 30 / ways[0] ;
			if(GetCommonDataDefault("KEITAI",0) == 2){break;}
			loop(10){yield}
		}
		loop{
			N_angle = angle;
			loop(ways[0]){
				CreateShot01(GetX, GetY, 3, angle,117,10);
				angle += 30 / ways[0];					
			}
			angle = N_angle + 30 / ways[0] ;
			if(GetCommonDataDefault("KEITAI",0) == 3){break;}
			loop(10){yield}
		}
		loop{
			N_angle = angle;
			loop(ways[1]){
				CreateShot01(GetX, GetY, 2, angle,117,10);
				angle += 50 / ways[1];					
			}
			angle = N_angle + 40 / ways[1] ;
			if(GetCommonDataDefault("KEITAI",0) == 4){break;}
			loop(10){yield}
		}
		loop{
			N_angle = angle;
			loop(ways[2]){
				CreateShot01(GetX, GetY, 1, angle,117,10);
				angle += 90 / ways[2];					
			}
			angle = N_angle + 90 / ways[2] ;
			loop(10){yield}
		}
	}
}
#include_script".\Item01.txt"
#include_script".\Item02.txt"
#include_script".\Item04.txt"

