
script_enemy_main {
	#include_function ".\lib\lib_anime_mokou.txt"
	#include_function ".\Draw.txt"
	#include_function ".\lib_Functions.txt"
	let imgBoss	=csd ~ "img\dot_mokou.png";
	let Back	=csd~"img\back3.png";

	@Initialize {
        	SetLife(500);
		SetTimer(70);
		SetScore(5000000);
		SetDamageRate(0, 0);
		SetDurableSpellCard;
		LastSpell;
		InitializeAction();
		LoadUserShotData(shotData);
		LoadGraphic(imgBoss);
		LoadGraphic(Back);
		Load;
        	CutIn(YOUMU,"転生「ソウル・オブ・フェニックス」", NULL, 0, 0, 0, 0);
        	Main;
	}

    	@MainLoop {
        	SetCollisionA(GetX, GetY, 32);
        	SetCollisionB(GetX, GetY, 16);
		if(GetTimer==10&&counter==0){
			Timer;
			counter++;
		}
        	yield;
    	}

	@DrawLoop {
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetAlpha(255);
		if(drawcount>1){
		DrawBoss(imgBoss);
		}
	}

	@BackGround {
		SetColor(100,100,255);
		SetTexture(Back);
		SetGraphicRect(0, 0, 384, 457);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(224, 240);
		if(drawcount==1){
			DrawHououZ(200, 200, 100, 100);
		}
		if(drawcount>0){
			DrawHouou(200, 200, 100, 100);
			DrawIrusion(GetX, GetY,100,255,100,100);
		}
	}

	sub standBy {
		SetMovePosition03(cenX,cenY-120, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(120);
	}

   	task Main {
        	yield;
		standBy;
		Charge;
		PlaySE(seCharge1);
		wait(10);
		drawcount++;
		wait(30);
		drawcount++;
		wait(60);
		SetDamageRate(0, 0);	
		Att;
		moveA;
	}

	task Att{
		let time=180;
		loop{
			if(GetTimer<40){time=120;}
			if(GetTimer<20){time=90;}
			Concentration01(90);
			PlaySE(seCharge1);
			wait(time);
			let angle=GetAngleToPlayer;
			CreateEnemyFromScript("PHOENIX", GetX, minY-100, 3.5, angle, 0);
			PlaySE(seFire);
			wait(time);
			yield;
		}
	}

	task moveA {
		loop{
      		wait(240);
		if(GetX<=GetPlayerX&&GetX<360||GetX<120){
			if(GetY>140){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX+50,GetY-30,30);
			}
			else if(GetY<100){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX+50,GetY+30,30);
			}
			else{
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX+50,GetY+rand(-30,30),30);
			}
		}
		else{
			if(GetY>140){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX-50,GetY-30,30);
			}
			else if(GetY<100){
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX-50,GetY+30,30);
			}
			else{
			SetAction(ACT_MOVE,60);
			SetMovePosition02(GetX-50,GetY+rand(-30,30),30);
			}
		}
		yield;
		}
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		Delete;
	}

}

script_enemy PHOENIX{
	let imgphoenix   = GetCurrentScriptDirectory ~ "img\phoenix.png";
	let z=0;
	let d=0;
	let angle=GetAngle;

	@Initialize{
       	 	SetLife(500);
		LoadGraphic(imgphoenix);
		Main;
	}

	@DrawLoop{
		SetTexture(imgphoenix);
		SetRenderState(ADD);
		SetGraphicRect(1,0,198,200);
		SetGraphicScale(1.5,1.5);
		SetGraphicAngle(0, 0, angle+90);
		SetColor(255, 255, 255);
		DrawGraphic(GetX, GetY);
		AuraEffect;
	}

	task AuraEffect{
		let x=GetX;let y=GetY;
		let Obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(Obj,imgphoenix);
		ObjEffect_SetLayer(Obj,1);
		ObjEffect_SetRenderState(Obj,ADD);
		ObjEffect_SetPrimitiveType(Obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(Obj,4);
		ObjEffect_SetAngle(Obj,0,0,angle+90);

		ObjEffect_SetVertexXY(Obj, 0, -99, -100);
		ObjEffect_SetVertexXY(Obj, 1, -99,  100);
		ObjEffect_SetVertexXY(Obj, 2,  99, -100);
		ObjEffect_SetVertexXY(Obj, 3,  99, 100);

		ObjEffect_SetVertexUV(Obj, 0, 1, 0);
		ObjEffect_SetVertexUV(Obj, 1, 1, 200);
		ObjEffect_SetVertexUV(Obj, 2, 198, 0);
		ObjEffect_SetVertexUV(Obj, 3, 198, 200);

		let scale=1.5;let alpha=128;
		while(alpha>10)
		{
			Obj_SetPosition(Obj,x,y);
			ObjEffect_SetScale(Obj,scale,scale);
			ascent(a in 0..4)
			{
				ObjEffect_SetVertexColor(Obj,a,alpha,255,255,255);
			}
			alpha-=5;
			scale+=0.01;
			yield;
		}
		Obj_Delete(Obj);
	}

	@MainLoop{
		SetCollisionB(GetX, GetY, 80);
		SetCollisionB(GetX+100*cos(angle), GetY+100*sin(angle), 40);
		SetCollisionB(GetX+90*sin(angle+50), GetY-90*cos(angle+50), 30);
		SetCollisionB(GetX+100*sin(angle+40), GetY-100*cos(angle+40), 30);
		SetCollisionB(GetX+110*sin(angle+30), GetY-110*cos(angle+30), 30);
		SetCollisionB(GetX+90*sin(angle+130), GetY-90*cos(angle+130), 30);
		SetCollisionB(GetX+100*sin(angle+140), GetY-100*cos(angle+140), 30);
		SetCollisionB(GetX+110*sin(angle+150), GetY-110*cos(angle+150), 30);
		yield;
	}

	task Main{
		yield;
		shotA;
		shotB;
		shotC;
		shotD;
		shotE;
		shotF;
		shotG;
		shotH;
		shotI;
	}

	task shotA{
		let A=0;
		loop{
			CreateShot02(GetX-140*cos(angle+8),GetY-140*sin(angle+8),1,angle-90,0.05,2+0.5*sin(A),245,0);
			CreateShot02(GetX-140*cos(angle-8),GetY-140*sin(angle-8),1,angle+90,0.05,2+0.5*sin(A),245,0);
			A+=10;
			wait(8);
			yield;
		}
	}

	task shotB{
		let A=0;
		loop{
			CreateShot02(GetX-150*cos(angle+18),GetY-150*sin(angle+18),0.2,angle-90,0.05,1.5+0.5*sin(A),244,0);
			CreateShot02(GetX-150*cos(angle-18),GetY-150*sin(angle-18),0.2,angle+90,0.05,1.5+0.5*sin(A),244,0);
			A+=20;
			wait(8);
			yield;
		}
	}

	task shotC{
		let A=0;
		loop{
			CreateShot02(GetX-140*cos(angle+30),GetY-140*sin(angle+30),3,angle-90,-0.05,1+0.2*sin(A),243,0);
			CreateShot02(GetX-140*cos(angle-30),GetY-140*sin(angle-30),3,angle+90,-0.05,1+0.2*sin(A),243,0);
			A+=30;
			wait(8);
			yield;
		}
	}

	task shotD{
		let A=0;
		loop{
			CreateShot02(GetX-155*cos(angle+40),GetY-155*sin(angle+40),1.5,angle-90,0.05,2.5+0.2*sin(A),247,0);
			CreateShot02(GetX-155*cos(angle-40),GetY-155*sin(angle-40),1.5,angle+90,0.05,2.5+0.2*sin(A),247,0);
			A+=20;
			wait(8);
			yield;
		}
	}

	task shotE{
		loop{
			CreateShot02(GetX-70*cos(angle),GetY-70*sin(angle),rand(4,2),angle+rand(60,100),-0.05,rand(0.5,1),241,0);
			CreateShot02(GetX-70*cos(angle),GetY-70*sin(angle),rand(4,2),angle-rand(60,100),-0.05,rand(0.5,1),241,0);
			wait(2);
			yield;
		}
	}

	task shotF{
		let A=0;
		loop{
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle+40*sin(A)-180,241,0);
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle-40*sin(A)-180,245,0);
			A+=2;
			yield;
		}
	}

	task shotG{
		let A=0;
		loop{
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle+40*sin(A)-180,243,0);
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle-40*sin(A)-180,244,0);
			A+=9;
			yield;
		}
	}

	task shotH{
		let A=0;
		loop{
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle+40*sin(A)-180,246,0);
			CreateShot01(GetX-70*cos(angle),GetY-70*sin(angle),3,angle-40*sin(A)-180,247,0);
			A+=3;
			yield;
		}
	}

	task shotI{
		loop{
			CreateShot01(GetX+rand(-148,148)*sin(angle),GetY+rand(-148,148)*cos(angle),2,angle-180,242,0);
			CreateShot01(GetX+rand(-148,148)*sin(angle),GetY+rand(-148,148)*cos(angle),2,angle-180,242,0);
			wait(1);
			yield;
		}
	}

	@Finalize{
	}

function wait(let n){loop(n){yield;}}
}