#Title[模擬「銀閣寺の安っすい天井」]
#Text[古明地さとりのスペルカード]
#BackGround[Default]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name="模擬「銀閣寺の安っすい天井」";
        let csd=GetCurrentScriptDirectory;
        let imgBoss=csd~"img\ExSatori.png";
	let Animation=0;
        let ranX=0;
        let ranY=0;
        let angle=0;
        let ranA=0;
	let Motion=0;
	let shotseA=csd~"se\ShotSE02.wav";
	let shotseB=csd~"se\ShotSE01.wav";
	let shotseD = csd~"se\BOM.wav";
	let Flag=false;

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

        SetLife(500);
        SetTimer(35);
        SetScore(1000000);
        SetDamageRate(20,20);

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

        @MainLoop
        {
	if(count>=150&&count%5==0){
		PlaySE(shotseA);
		ranX=rand(-10,10);
		ranY=rand(-10,10);
		ranA=rand(-10,10);
		let i=0;
		while(i<5)
		{
			let shotA=0;
			CreateShotA(shotA,GetX+ranX,GetY+ranY,5);
			SetShotDataA(shotA,0,2,angle+i*72+ranA,0,0,2,5);
			FireShot(shotA);
			i++;
			}
		angle+=4;
		}
	if(count>=150&&count%50==0){
		PlaySE(shotseB);
		ranX=rand(-35,35);
		ranY=rand(-35,35);
		let i=3;
		while(i<20)
		{
			let shotA=0;
			CreateShotA(shotA,GetX+ranX,GetY+ranY,5);
			SetShotDataA(shotA,0,0.5*i,180,0,-0.01*i,0,8);
			SetShotDataA(shotA,51,1.5,95,0,0,1.5,8);
			FireShot(shotA);
			i++;
			}
		}
	if(count>=150&&count%50==25){
		PlaySE(shotseB);
		ranX=rand(-35,35);
		ranY=rand(-35,35);
		let i=3;
		while(i<20)
		{
			let shotA=0;
			CreateShotA(shotA,GetX+ranX,GetY+ranY,5);
			SetShotDataA(shotA,0,0.5*i,0,0,-0.01*i,0,8);
			SetShotDataA(shotA,51,1.5,85,0,0,1.5,8);
			FireShot(shotA);
			i++;
			}
		}
        if(GetEnemyLife<1&&!Flag){
		Flag=true;
		Explosion01(GetX(),GetY(),1/60*255,0.3,60);
		PlaySE(shotseD);
        	}
        SetCollisionB(GetX(),GetY(),22);
	SetCollisionA(GetX(),GetY(),22);
        count++;
        }

	@Finalize {
		PlaySE(shotseD);
		DeleteGraphic(imgBoss);
	}

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgBoss);
		SetGraphicScale(1,1);
		SetAlpha(255);
		SetColor(255,255,255);
		SetGraphicAngle(0,0,0);
	if(Motion==0){
		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);}
		}
	if(Motion==1){
		SetGraphicRect(0,0,127,127);
		}
		DrawGraphic(GetX(),GetY());
	}
}
