#e
#Title[utFA[Y_[hv]
#Text[d̃XyJ[h]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
        let count=0;
        let name    = "utFA[Y_[hv";
        let csd     = GetCurrentScriptDirectory;
        let imgBoss =csd~"img\dot_daiyousei.png";
	let imgEnemy=csd~"img\familiar2.png";
        let imgSPELL =csd~"img\SPELL_H.png";
	let big=0;
	let imgAngle=0;
	let imgALP1=255;
	let imgALP2=0;
	let imgBACK=0;
	let retune=0;
	let Kousoku=false;
	let bigX=1;
	let bigY=1;
	let angle=0;
	let countA=0;
        let cx=GetCenterX();
        let cy=GetCenterY();
	let AnimationA=0;
	let AnimationB=0;
	let AnimationC=0;
	let shotseA = csd~"se\ShotSE02.wav";
	let shotseB = csd~"se\Powar.wav";

    @Initialize {
        CutIn(YOUMU,name,0,0,0,0,0);
        SetLife(3500);
        SetTimer(66);
        SetScore(1000000);
        SetDamageRate(0,0);
        SetDurableSpellCard;
        SetInvincibility(200);
	LoadGraphic(imgBoss);
	LoadGraphic(imgEnemy);
	LoadGraphic(imgSPELL);
        TAnime1;
        }

        @MainLoop
        {
	imgAngle+=5;
	if(imgAngle>=360){imgAngle=0;}
	if(retune==0&&big<99){big+=2;}
	if(retune==1&&big>1){big-=2;}
	imgBACK+=4;
	if(imgBACK==448){imgBACK=0;}

	if(count>=50&&count%100==0){
        	retune=1;
		}
	if(count>=50&&count%100==50){
        	retune=0;
		}
        if(!OnBomb&&Kousoku==false){
        imgALP2=255;
        imgALP1=100;
	SetDamageRate(0,0);
        SetEnemyMarker(true);}
        else {
        imgALP2=100;
        imgALP1=255;
	SetDamageRate(0,0);
	SetEnemyMarker(false);}

	if(count==150){
		PlaySE(shotseB);
		Concentration02(60);
        	}
	if(count>=200&&count<=224){
		bigX+=0.04;
		bigY-=0.04;
        	}
	if(count>=225&&count<=249){
		bigX-=0.04;
		bigY+=0.04;
        	}
	if(count==225){
		Kousoku=true;
        	}
	if(count>=250&&count%500==0){
		PlaySE(shotseB);
		SetMovePosition01(GetPlayerX,GetPlayerY,1);
		countA++;
        	}
	if(count>=250&&count%20==0){
		PlaySE(shotseA);
		angle=rand(0,360);
		let i=0;
		while(i<20){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX+cos(i*18+angle)*20,GetY+sin(i*18+angle)*20,5);
			SetShotDataA(shotA,0,1,i*18+angle,0,0,0,BLUE22);
			FireShot(shotA);
			i=i+1;
			}
	if(countA>3){
		let i=0;
		while(i<10){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX+cos(i*36+angle)*20,GetY+sin(i*36+angle)*20,5);
			SetShotDataA(shotA,0,1.5,i*36+angle,0,0,0,AQUA22);
			FireShot(shotA);
			i=i+1;
			}
        	}
	if(countA>6){
		let i=0;
		while(i<20){
        		SetShotDirectionType(ABSOLUTE);
			let shotA=0;
			CreateShotA(shotA,GetX+cos(i*18+angle)*20,GetY+sin(i*18+angle)*20,5);
			SetShotDataA(shotA,0,2,i*18+angle-180,0,0,0,WHITE22);
			FireShot(shotA);
			i=i+1;
			}
        	}
        	}
        count++;
        yield;
        }

        @DrawLoop {
		SetRenderState(ALPHA);
		SetTexture(imgEnemy);
		SetGraphicRect(0,0,192,192);
		SetAlpha(imgALP1);
		SetColor(0,255,128);
		SetGraphicScale(0.01*big,1);
		SetGraphicAngle(0,0,imgAngle);
		DrawGraphic(GetX(),GetY());

		SetColor(0,128,255);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetX(),GetY());

		SetTexture(imgBoss);
		SetGraphicScale(bigX,bigY);
		SetAlpha(imgALP2);
		SetColor(imgALP2,imgALP2,imgALP2);
		SetGraphicAngle(0,0,0);
		SetGraphicRect(128*AnimationC,128*AnimationB,127+128*AnimationC,127+128*AnimationB);
		DrawGraphic(GetX(),GetY());
	}

	@BackGround
	{
		//wi`
		SetGraphicRect(0,0,384,448);
		SetTexture(imgSPELL);
		SetRenderState(ALPHA);
		SetColor(255,255,255);
		SetAlpha(155);
		SetGraphicScale(1,1);
		DrawGraphic(cx,cy-448+imgBACK);

		DrawGraphic(cx,cy+imgBACK);
	}
        
        @Finalize
        {
        } 
	
    	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;}
			AnimationB=3;
        		loop(10){yield;}
			}
		}

    	task Slaser{
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,-10,rand(40,350));
		Obj_SetAngle(obj,rand(-15,15));
		ObjShot_SetGraphic(obj,72);
		ObjShot_SetDelay(obj,25);
		ObjLaser_SetSource(obj,false);
		ObjLaser_SetWidth(obj,30);
		ObjLaser_SetLength(obj,1000);
		loop(150){yield;}
		ObjShot_FadeDelete(obj);
	}
}