#e
#Title[񑥘Agu䊍ʓev]
#Text[񑥎ÕXyJ[h]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let name    = "񑥘Agu䊍ʓev";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss1 =csd~"img\dot_sanae.png";
        let imgBoss2 =csd~"img\dot_meirin.png";
        let imgBoss3 =csd~"img\dot_cirno.png";
        let angle=0;
	let AnimationB=0;
	let AnimationA=0;

    @Initialize {
        CutIn(YOUMU, name, 0, 0, 0, 0, 0);
        SetLife(4000);
        SetTimer(70);
        SetScore(1000000);
        SetDamageRate(100,20);
        SetMovePosition02(cx,120,60);
        SetInvincibility(200);
        LoadGraphic(imgBoss1);
        LoadGraphic(imgBoss2);
        LoadGraphic(imgBoss3);
	CreateEnemyFromScript("LUNA",GetX,GetY,0,0,1);
	CreateEnemyFromScript("STAR",GetX,GetY,0,0,1);
        TAnime;
    }

        @MainLoop
        {
        SetCollisionB(GetX(),GetY(),24);
	SetCollisionA(GetX(),GetY(),32);
        count++;
        yield;
        }

        @DrawLoop {
	SetRenderState(ALPHA);
	SetTexture(imgBoss1);
	SetGraphicScale(1,1);
	SetAlpha(255);
	if(int(GetSpeedX())==0)
	{SetGraphicRect(128*AnimationA,128*AnimationB,127+128*AnimationA,127+128*AnimationB);}
	else if(GetSpeedX()>0){SetGraphicRect(256,384,383,511);}
	else if(GetSpeedX()<0){SetGraphicRect(256,128,383,255);}
	DrawGraphic(GetX(),GetY());
	}

    @Finalize {
    }

    	task TAnime{
		loop(6){
			AnimationB=0;
			AnimationA=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
			AnimationB=0;
			AnimationA=5;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
		}
}

script_enemy LUNA {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let csd     = GetCurrentScriptDirectory;
        let imgBoss2 =csd~"img\dot_meirin.png";
        let angle = 0;
	let Animation=0;

    @Initialize {
        SetLife(5000);
        SetDamageRateEx(0,0,100,20);
        SetMovePosition02(cx+100,150,60);
        SetInvincibility(200);
        TAnime;
    }

        @MainLoop
        {
	if(count==200){
		angle = atan2(GetEnemyY()-GetPlayerY(),GetEnemyX()-GetPlayerX());
		SetMovePosition02(GetEnemyX+cos(angle)*100,GetEnemyY+sin(angle)*100,40);
		}

	if(count>=250&&count<=350){
        	SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,PURPLE12);
			SetShotDataA(shotA,375-count,5,360/7+angle,0,-0.1,0,PURPLE12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,PURPLE23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,BLUE12);
			SetShotDataA(shotA,375-count,5,360/7*2+angle,0,-0.1,0,BLUE12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,BLUE23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,AQUA12);
			SetShotDataA(shotA,375-count,5,360/7*3+angle,0,-0.1,0,AQUA12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,AQUA23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,GREEN12);
			SetShotDataA(shotA,375-count,5,360/7*4+angle,0,-0.1,0,GREEN12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,GREEN23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,YELLOW12);
			SetShotDataA(shotA,375-count,5,360/7*5+angle,0,-0.1,0,YELLOW12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,YELLOW23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,ORANGE12);
			SetShotDataA(shotA,375-count,5,360/7*6+angle,0,-0.1,0,ORANGE12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,ORANGE23);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,5);
			SetShotDataA(shotA,0,0,90,0,0,0,RED12);
			SetShotDataA(shotA,375-count,5,angle,0,-0.1,0,RED12);
			SetShotDataA(shotA,425-count,0,atan2(GetEnemyY-GetY(),GetEnemyX-GetX())+45,0.2,rand(0.005,0.01),2,RED23);
			FireShot(shotA);
		}

	if(count>=200&&count%200==50){
		SetMovePosition02(GetEnemyX+cos(144+angle)*100,GetEnemyY+sin(144+angle)*100,20);
		}
	if(count>=200&&count%200==70){
		SetMovePosition02(GetEnemyX+cos(-72+angle)*100,GetEnemyY+sin(-72+angle)*100,20);
		}
	if(count>=200&&count%200==90){
		SetMovePosition02(GetEnemyX+cos(72+angle)*100,GetEnemyY+sin(72+angle)*100,20);
		}
	if(count>=200&&count%200==110){
		SetMovePosition02(GetEnemyX+cos(-144+angle)*100,GetEnemyY+sin(-144+angle)*100,20);
		}
	if(count>=200&&count%200==130){
		SetMovePosition02(GetEnemyX+cos(angle)*100,GetEnemyY+sin(angle)*100,20);
		}
	if(count>=400&&count%400==0){
		count=199
		}
        SetCollisionB(GetX(),GetY(),24);
	SetCollisionA(GetX(),GetY(),32);
        count++;
        yield;
        }

        @DrawLoop {
	SetRenderState(ALPHA);
	SetTexture(imgBoss2);
	SetGraphicScale(1,1);
	SetAlpha(255);
	if(int(GetSpeedX())==0)
	{SetGraphicRect(0,128*Animation,127,127+128*Animation);}
	else if(GetSpeedX()>0){SetGraphicRect(256,384,383,511);}
	else if(GetSpeedX()<0){SetGraphicRect(256,128,383,255);}
	DrawGraphic(GetX(),GetY());
	}

    @Finalize {
    }

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			}
		}
}


script_enemy STAR {
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let MAnimation=0;
	let r = 0;
        let angle = 0;
        let csd     = GetCurrentScriptDirectory;
        let imgBoss3 =csd~"img\dot_cirno.png";
	let Animation=0;

    @Initialize {
        SetLife(5000);
        SetDamageRateEx(0,0,100,20);
        SetMovePosition02(cx-100,150,60);
        SetInvincibility(200);
        TAnime;
    }

        @MainLoop
        {
	if(count>=200){
	MAnimation-=10;
	if(MAnimation<-360){MAnimation=0;}
        	if(count%2==0)
        	{
        	if(r<100)
        	{
		r=r+5;}
		SetMovePosition02(GetEnemyX+cos(angle)*r*2,GetEnemyY+sin(angle)*r/1.5,10);
        angle=angle+10;
        	}
		}

        if(count>=500&&count%25==0)
        {
        	let i = 0;
        	while( i < 18 )
        	{
		let id   = 0;
        	SetShotDirectionType(ABSOLUTE);
		CreateShotA(id,GetX,GetY,0);
		SetShotDataA(id,0,2,i*20,0,-0.01,1,BLUE04);
		FireShot(id);
        	i++;
		}
        }
        SetCollisionB(GetX(),GetY(),24);
	SetCollisionA(GetX(),GetY(),32);
        count++;
        yield;
        }

        @DrawLoop {
	SetRenderState(ALPHA);
	SetTexture(imgBoss3);
	SetGraphicScale(1,1);
	SetAlpha(255);
	if(int(GetSpeedX())==0)
	{SetGraphicRect(0,128*Animation,127,127+128*Animation);}
	else if(GetSpeedX()>0){SetGraphicRect(256,384,383,511);}
	else if(GetSpeedX()<0){SetGraphicRect(256,128,383,255);}
	DrawGraphic(GetX(),GetY());
	}

    @Finalize {
    }

    	task TAnime{
		loop{
			Animation=0;
        		loop(10){yield;}
			Animation=1;
        		loop(10){yield;}
			Animation=2;
        		loop(10){yield;}
			Animation=3;
        		loop(10){yield;}
			}
		}
}