#Title[さとり通常２]
#Text[古明地さとりの通常]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\Exsatori.png";
        let angle=0;
	let shotseA=csd~"se\Powar.wav";

    @Initialize {
        SetLife(2000);
        SetTimer(30);
        SetDamageRate(100,100);
	SetEnemyMarker(true);

        SetInvincibility(200);
	LoadGraphic(imgBoss);
	LoadUserShotData(csd~"img\PLUS_shot.txt");
	}

        @MainLoop
        {
	if(count>=100&&count%200==0){
		PlaySE(shotseA);
		let i=4;
		while(i<14){
			let j=0;
			while(j<10){
				let shotA=0;
				CreateShotA(shotA,GetX+cos(j*36+angle),GetY+sin(j*36+angle),50-(i*2));
				SetShotDataA(shotA,0,0,j*36+angle,0,0.05*i,i*0.25,226);
				FireShot(shotA);
				j++;
				}
			i++;
			angle+=18;
			}
		}
	if(count>=100&&count%200==100){
		PlaySE(shotseA);
		let i=4;
		while(i<14){
			let j=0;
			while(j<10){
				let shotA=0;
				CreateShotA(shotA,GetX+cos(j*36+angle),GetY+sin(j*36+angle),50-(i*2));
				SetShotDataA(shotA,0,0,j*36+angle,0,0.05*i,i*0.25,221);
				FireShot(shotA);
				j++;
				}
			i++;
			angle+=18;
			}
		}
	if(count>=200&&count%100==50){
		SetMovePositionRandom01(rand(50,100),rand(20,40),3,GetClipMinX()+150,150,GetClipMaxX()-150,200);
		}
        	SetCollisionA(GetX(),GetY(),22);
        	SetCollisionB(GetX(),GetY(),22);
        	count++;
	yield;
	}

	@Finalize {
		DeleteGraphic(imgBoss);
	}

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