#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
        #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);
	  SetDamageRate(0,0);
	  SetCountDown;
	  CreateEnemyFromScript("Sunny",GetX,GetY,0,0,0);//OL`
          Tmain;
	}
	
	@MainLoop
	{  
		if(OnEvent()==true){break;}
                yield;
                SetCollisionA(GetX(),GetY(),32);
		SetCollisionB(GetX(),GetY(),16);
		if(GetHitCount<=0){return;}
		if(Hitframe%4==0){
			PlaySE(Hit);
		}
		Hitframe++;
        } 
	
	@Finalize
	{       

	}

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

        task Tmain
        {
	 	SetMovePosition02(cx-250,cy-140,0);
		yield;
		//ÕXyǂ--------------------------------------------------------------
		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;
		//J[h
	 	SetDamageRate(120,50);
		SetTimer(31);
		yield;

		SetMovePosition03(cx,cy-120,10,6);//ʓړ---------------------------------------------
	 	SetAction(ACT_MOVE,60);
		loop(60){yield;}
	 	SetDamageRate(100,20);
		//e-------------------------------------------------------------------------------------
		SetAction(ACT_SHOT_B,120);
		alternative(Level)
		case(1){//hard
			let ways = 6;
			Shot01(ways);
			Shot02(ways);
		}
		case(0){//easy
			let ways = 3;
			Shot01(ways);
			Shot02(ways);
		}
	}

	task Shot01(ways){
		let angle = 90;
		loop{
			PlaySE(arrow01);
			loop(ways){
				Shot01b(angle);
				angle += 360 / ways;
			}
			loop(10){yield;}
			angle += 11;
		}
	}
	task Shot01b(angle){
		let speed = 4.0;
		loop(6){
			CreateShot01(GetX + 30 * cos(angle) ,GetY + 30 * sin(angle),speed,angle,157,5);
			speed -= 0.3;
			angle += 1;
		}
	}

	task Shot02(ways){
		let angle = 90;
		loop{
			loop(ways){
				Shot02b(angle);
				angle += 360 / ways;
			}
			loop(10){yield;}
			angle -= 11;
		}
	}
	task Shot02b(angle){
		loop(3){
			CreateShot01(GetX + 10 * cos(angle) ,GetY + 10 * sin(angle),3,angle,158,5);
			angle -= 1;
		}
	}

	task TMove(){
 		if(GetX>=GetPlayerX){SetMovePositionRandom01(40,30,2,GetX-40,cy-160,GetX-41,cy-80);}
 		if(GetX<=GetPlayerX){SetMovePositionRandom01(40,30,2,GetX+40,cy-160,GetX+41,cy-80);}
		if(GetX>=cx+50){SetMovePositionRandom01(40,30,2,GetX-40,cy-160,GetX-41,cy-80);}
		if(GetX<=cx-50){SetMovePositionRandom01(40,30,2,GetX+40,cy-160,GetX+41,cy-80);}
		SetAction( ACT_MOVE, 60 );
	}

        task effectshot(X,Y,delay,col){
                  CreateShotA(1,X,Y,delay);
                  SetShotDataA(1,0,0,0,0,0,0,7);
                  SetShotKillTime(1,0);
                  FireShot(1);
        }
}

script_enemy Sunny{
	#include_function ".\lib\lib_anime_Sunnymilk.txt"
	let imgBoss=GetCurrentScriptDirectory~"img\Boss\dot_sunnymilk.png";
	let Item  	=GetCurrentScriptDirectory~"\img\effect_tiny.png";
	#include_function ".\lib\lib_EnemyMarker.txt"
	EnemyMarker;
        let cx=GetCenterX;
        let cy=GetCenterY;
    	@Initialize
        {
          InitializeAction();
          LoadGraphic(imgBoss);
          SetInvincibility(90);
          SetLife(4000);
          Tmain;

	}

	@MainLoop
	{  
                yield;
        } 
	@Finalize
	{       

	}
	@DrawLoop
	{//`
                SetColor(255,255,255);
		SetRenderState(ALPHA);
		DrawBoss( imgBoss );
	}
        
        task Tmain
        {
                SetAction( ACT_MOVE, 60 );
		SetMovePosition03(cx+300,cy-150,10,6);//ʊOړ
		loop(60){yield;}
		VanishEnemy;//폜

        }
        task Tmove(){
                 if(GetX>=cx+100){SetMovePositionRandom01(70,20,2,GetX-70,cy-120,GetX-71,cy-60);}
                 else if(GetX<=cx-100){SetMovePositionRandom01(70,20,2,GetX+70,cy-120,GetX+71,cy-60);}
                 else if(GetX>=GetPlayerX){SetMovePositionRandom01(70,20,2,GetX-70,cy-120,GetX-71,cy-60);}
                 else if(GetX<=GetPlayerX){SetMovePositionRandom01(70,20,2,GetX+70,cy-120,GetX+71,cy-60);}
                 SetAction( ACT_MOVE, 60 );
        }
}
