#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 angle=rand(0,360);
	let angleB=0;
	let x1=0;
	let y1=0;
	let x2=0;
	let y2=0;
	let j=1;
	let w=1;
        let retrun=1;
        let Rcount=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let Motion=0;
	let shotseA=csd~"se\ShotSE02.wav";
	let shotseC=csd~"se\ShotSE03.wav";

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

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

        SetInvincibility(200);
	LoadGraphic(imgBoss);
        SetMovePosition02(cx,150,60);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
    }

        @MainLoop
        {
	if(count==150){
		Motion=1;
		Concentration01(60);
		}
	if(count>=200&&count%4==0){
		PlaySE(shotseA);
		SetShotDirectionType(ABSOLUTE);
		let i=0;
		while(i<6){
			let shotA=0;
			CreateShotA(shotA,GetX+7,GetY-38,5);
			SetShotDataA(shotA,0,1,i*60+j,0,0.01,2,61);
			FireShot(shotA);
			i++;
			}
		angle+=5;
		}
	if(count>199&&retrun==1){j=j+w;
		w=w+0.02;}
		else if(count>199&&retrun==0){j=j+w;
		w=w-0.04;}
	if(count<600&&count>=400){
		retrun=1;
		}
	if(count<800&&count>=600){
		retrun=0;
		}
	if(count>=800){
		count=400;
		Rcount=1;
		}
	if(count>=200&&count%25==0&&Rcount==1){
		PlaySE(shotseC);
		}
	if(count>=200&&count%50==0&&Rcount==1){
		x1=rand(16,432);
		y1=rand(16,120);
		angle=atan2(GetPlayerY-y1,GetPlayerX-x1);
		let i=0;
		while(i<50){
			let shotA=0;
			CreateShotA(shotA,x1,y1,i);
			SetShotDataA(shotA,0,3,angle,0,0,0,152);
			FireShot(shotA);
			i++;
			}
		}
	if(count>=200&&count%50==25&&Rcount==1){
		x2=rand(16,432);
		y2=rand(16,120);
		angleB=atan2(GetPlayerY-y2,GetPlayerX-x2);
		let i=0;
		while(i<50){
			let shotA=0;
			CreateShotA(shotA,x2,y2,i);
			SetShotDataA(shotA,0,3,angleB,0,0,0,152);
			FireShot(shotA);
			i++;
			}
		}
	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(Motion==0){SetGraphicRect(128,0,255,127);}
		else {SetGraphicRect(0,128,127,255);}
		DrawGraphic(GetX(),GetY());
	}

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