#Title[鎧符「人形行軍」]
#Text[アリスのスペルカード]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="鎧符「人形行軍」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\dot_EXalice.png";
        let imgBoss2=csd~"img\dot_yousei.png";
        let angle=0;
        let i=0;
	let Motion=0;
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);

        SetLife(600);
        SetTimer(50);
        SetScore(1500000);
        SetDamageRate(45,20);

        SetInvincibility(300);
        SetMovePosition02(GetCenterX(),150,50);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
        TAnime1;
    }

        @MainLoop
        {
	if(count==150){
		Concentration01(60);
		}
	if(count==200){
		let i=0;
		while(i<10){
			CreateEnemyFromScript("DOLLA",GetX,GetY,1,i*36,0);
			i++;
			}
		}
	if(count>=300&&count%10==0){
        	SetMovePosition01(GetPlayerX,GetPlayerY,0.75);
                TAnime2;
		}
	if(count>=300&&count%600==300){
        	SetShotDirectionType(ABSOLUTE);
		let i=0;
		while(i<6){
			let laser=0;
			CreateLaserB(laser,0,20,73,50);
			SetLaserDataB(laser,0,20,0,0,0,0,i*60,0.1);
			SetShotKillTime(laser,150);
			FireShot(laser);
			i++;
			}
		}
	if(count>=300&&count%600==0){
        	SetShotDirectionType(ABSOLUTE);
		let i=0;
		while(i<6){
			let laser=0;
			CreateLaserB(laser,0,20,73,50);
			SetLaserDataB(laser,0,20,0,0,0,0,i*60,-0.1);
			SetShotKillTime(laser,150);
			FireShot(laser);
			i++;
			}
		}
        SetCollisionA(GetX(),GetY(),18);
        SetCollisionB(GetX(),GetY(),18);
        count++;
        yield;

}
	@Finalize {
		if(!IsTimeOut){
			loop(50){
				angle=rand(0,360);
				CreateItem(ITEM_SCORE,GetX+cos(angle)*rand(35,45),GetY+sin(angle)*rand(35,45));
			}
		}
		DeleteGraphic(imgBoss);
		DeleteGraphic(imgBoss2);
	}

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

    	task TAnime1{
			AnimationB=0;
			AnimationC=3;
        		loop(16){yield;}
			AnimationB=1;
        		loop(56){yield;}
			AnimationB=0;
        		loop(8){yield;}
		loop{
			AnimationB=0;
			AnimationC=0;
        		loop(10){yield;}
			AnimationB=1;
        		loop(10){yield;}
			AnimationB=2;
        		loop(10){yield;}
			}
		}

    	task TAnime2{
			AnimationA=0;
        		loop(5){yield;}
			AnimationA=1;
        		loop(10){yield;}
			AnimationA=0;
        		loop(5){yield;}
		}
}

script_enemy DOLLA{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Animation=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei.png";
	let angle=GetAngle;
	let imgAngle=0;
	let imgAlpha=255;
	let deathse=csd~"se\DEATH.wav";
        let r=0;
	let shotseA=csd~"se\ShotSE02.wav";

    @Initialize {
        SetLife(100);
        SetInvincibility(50);
        TAnime;
	}

	@MainLoop {
	if(count==49){
		r=((GetX-GetEnemyX)^2+(GetY-GetEnemyY)^2)^0.5
		}
	if(count>=50&&count%5==0){
		SetMovePosition02(GetEnemyX+cos(angle)*r,GetEnemyY+sin(angle)*r,10);
		angle+=10;
		}
	if(count>=100&&count%50==0){
        	SetShotDirectionType(PLAYER);
		PlaySE(shotseA);
		let i=0;
		while(i<8){
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2.5,i*45,0,0,2.5,164);
			FireShot(shotA);
			i++;
			}
		}
	SetCollisionB(GetX(),GetY(),10);
	count++;
	yield;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,imgAngle);
		SetAlpha(imgAlpha);
		if(int(GetSpeedX())==0)
		{SetGraphicRect(Animation*32,128,31+Animation*32,159)}
		else if(GetSpeedX()>0){SetGraphicRect(128+Animation*32,160,159+Animation*32,191);}
		else if(GetSpeedX()<0){SetGraphicRect(Animation*32,160,31+Animation*32,191);}
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
        } 

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