#Title[葬符「火車の墓荒らし」]
#Text[火焔猫燐のスペルカード]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = "葬符「火車の墓荒らし」";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\ExOrin.png";
        let imgBoss2=csd~"img\dot_yousei3.png";
        let imgBoss3=csd~"img\familiar.png";
	let angle=0;
	let angleA=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;

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

        SetLife(400);
        SetTimer(60);
        SetScore(3000000);
        SetDamageRate(20,20);

        SetInvincibility(200);
        SetMovePosition02(GetCenterX(),30,60);
	LoadGraphic(imgBoss);
	LoadGraphic(imgBoss2);
	LoadGraphic(imgBoss3);
    }

        @MainLoop
        {
	if(count>=73&&count%73==0){
		angle=rand_int(0,72)*5;
		CreateEnemyFromScript("Enemy1",cx+cos(angle)*150,cy+sin(angle)*150,0,0,0);
		CreateEnemyFromScript("Enemy2",cx+cos(angle)*150,cy+sin(angle)*150,0,0,0);
		}
	if(count>=73&&count%73==72){
		let i=0;
		while(i<18){
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,1,angle+20*i,0,0,1,221);
			FireShot(shotA);
			i++;
			}
		SetMovePosition02(cx+cos(angle)*150,cy+sin(angle)*150,30);
		}
        SetCollisionB(GetX(),GetY(),18);
	SetCollisionA(GetX(),GetY(),18);
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
		if(GetSpeedX()==0){SetGraphicRect(0,256,127,382);}
		else if(GetSpeedX()<0){SetGraphicRect(0,256,127,382);}
		else if(GetSpeedX()>0){SetGraphicRect(128,256,255,382);}
		DrawGraphic(GetX(),GetY());
	}

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

script_enemy Enemy1{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
        let imgBoss3=csd~"img\familiar.png";
	let imgAngle=0;
	let imgAlpha=0;
	let imgAlpha2=0;

	@Initialize {
	SetLife(1);
	SetScore(0);
	SetDamageRate(0,0);
	SetX(GetX);
	SetY(GetY);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
	}

	@MainLoop {
	if(count<=50){
		imgAngle+=6;
		imgAlpha+=5;
		imgAlpha2+=5;
		if(imgAngle>=360){imgAngle=0;}
		}
	if(count>50&&count<=101){
		imgAngle+=6;
		imgAlpha-=5;
		if(imgAngle>=360){imgAngle=0;}
		}
	if(count>101&&count<=152){
		imgAlpha2-=5;
		}
        if(count>=153)
        	{
        	VanishEnemy();
        	}
	count++;
	}

        @DrawLoop {
		SetTexture(imgBoss3);
		SetGraphicAngle(0,0,imgAngle);
		SetAlpha(imgAlpha);
		SetGraphicRect(0,0,48,48);
		DrawGraphic(GetX(),GetY());
		SetGraphicAngle(0,0,-imgAngle);
		SetGraphicRect(0,0,48,48);
		DrawGraphic(GetX(),GetY());
		SetTexture(imgBoss2);
		SetGraphicAngle(0,0,0);
		SetAlpha(imgAlpha2);
		SetGraphicRect(261,0,282,31);
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
        }
}

script_enemy Enemy2{
        let count=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
        let csd=GetCurrentScriptDirectory;
        let imgBoss2=csd~"img\dot_yousei3.png";
	let imgAngle2=0;
	let imgAlpha2=0;
	let deathse=csd~"se\Hitugi.wav";

	@Initialize {
	SetLife(1);
	SetScore(0);
	SetDamageRateEx(0,0,0,0);
	SetX(GetX);
	SetY(GetY);
	}

	@MainLoop {
	if(count<=50){
		imgAlpha2+=5;
		}
	if(count==102){
		SetMovePositionHermite(GetX-40,GetY-30,60,225,10,90,51);
		PlaySE(deathse);
        	SetShotDirectionType(PLAYER);
		let i=0;
		while(i<16){
			let shotA=0;
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,4,i*22.5,0,-0.1,3,41);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,3,i*22.5,0,-0.1,2,41);
			FireShot(shotA);
			CreateShotA(shotA,GetX,GetY,0);
			SetShotDataA(shotA,0,2,i*22.5,0,-0.1,1,41);
			FireShot(shotA);
			i++;
			}
		}
	if(count>101&&count<=152){
		imgAngle2+=4;
		if(imgAngle2>=90){imgAngle2=90;}
		imgAlpha2-=5;
		}
        if(count>=153)
        	{
        	VanishEnemy();
        	}
	count++;
	}

        @DrawLoop {
		SetTexture(imgBoss2);
		SetGraphicAngle(imgAngle2,imgAngle2,0);
		SetAlpha(imgAlpha2);
		SetGraphicRect(229,0,250,31);
		DrawGraphic(GetX(),GetY());
	}

        @Finalize
        {
        }
}