
//=======================================================================
//　風神録以降の敵の魔法陣を表示する関数集です。
//　このファイルをinclude_functionで取り込むか、
//　必要な部分をコピペして使用してください。
//=======================================================================

//=======================================================================
// ■ 画像へのパス 構成が違う場合は要変更
//-----------------------------------------------------------------------
let imgmagic1 = GetCurrentScriptDirectory~"img/magic01.png";
let imgmagic2 = GetCurrentScriptDirectory~"img/magic02.png";
//=======================================================================

//-----------------------------------------------------------------------
// ■ 紅魔法陣 [th10〜th13]
//-----------------------------------------------------------------------
task MagicCircleEx(enemy,direct) {

	CreateCommonDataArea("circle");

	let magic	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let alpha	= 200;
	let R		= 240*alpha/255;
	let G		= 240*alpha/255;
	let B		= 240*alpha/255;
	let anglez	= 0;
	let scale1	= 0;
	let scale2	= 0;
	let scale3	= 0;

	LoadTexture(imgmagic1);

	ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(magic,imgmagic1);
	ObjRender_SetBlendType(magic,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(magic,PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(magic,25);
	ObjRender_SetScaleXYZ(magic,scale1,scale1,1);
	ObjPrim_SetVertexCount(magic,4);
	ObjPrim_SetVertexPosition(magic,0,-128,-128,0);
	ObjPrim_SetVertexPosition(magic,1,-128, 128,0);
	ObjPrim_SetVertexPosition(magic,2, 128,-128,0);
	ObjPrim_SetVertexPosition(magic,3, 128, 128,0);
	ObjPrim_SetVertexUVT(magic,0,  0,  0);
	ObjPrim_SetVertexUVT(magic,1,  0,256);
	ObjPrim_SetVertexUVT(magic,2,256,  0);
	ObjPrim_SetVertexUVT(magic,3,256,256);
	ObjPrim_SetVertexColor(magic,0,R,G,B);
	ObjPrim_SetVertexColor(magic,1,R,G,B);
	ObjPrim_SetVertexColor(magic,2,R,G,B);
	ObjPrim_SetVertexColor(magic,3,R,G,B);

	loop(60) {
		scale2 += 90/60;
		scale3  = 0.90*sin(scale2);
		scale1  = 0.10*sin(scale2);
		anglez  = 360*sin(-scale2);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,0,0,anglez);
		if(direct) { yield; }
	}
	if(!direct) { anglez = GetAreaCommonData("circle","circleanglez",0); scale2 = GetAreaCommonData("circle","circlescale",0); }
	while(!Obj_IsDeleted(enemy)) {
		anglez -= 360/60;
		scale2 += 360/120;
		scale1  = 0.10*sin(scale2);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,0,0,anglez);
		SetAreaCommonData("circle","circleanglez",anglez);
		SetAreaCommonData("circle","circlescale",scale2);
		yield;
	}
        Obj_Delete(magic);
}

//-----------------------------------------------------------------------
// ■ 紅魔法陣 [th14]
//-----------------------------------------------------------------------
task MagicCircleEx2(enemy,direct) {

	CreateCommonDataArea("circle");

	let magic	= ObjPrim_Create(OBJ_PRIMITIVE_2D);
	let alpha	= 144;
	let R		= 240*alpha/255;
	let G		= 240*alpha/255;
	let B		= 240*alpha/255;
	let lean	= 28;
	let anglex	= 0;
	let angley	= 0;
	let anglez	= 0;
	let scale1	= 0;
	let scale2	= 0;
	let scale3	= 0;

	LoadTexture(imgmagic2);

	ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
	ObjPrim_SetTexture(magic,imgmagic2);
	ObjRender_SetBlendType(magic,BLEND_ADD_RGB);
	ObjPrim_SetPrimitiveType(magic,PRIMITIVE_TRIANGLESTRIP);
	Obj_SetRenderPriorityI(magic,25);
	ObjRender_SetScaleXYZ(magic,scale1,scale1,1);
	ObjPrim_SetVertexCount(magic,4);
	ObjPrim_SetVertexPosition(magic,0,-128,-128,0);
	ObjPrim_SetVertexPosition(magic,1,-128, 128,0);
	ObjPrim_SetVertexPosition(magic,2, 128,-128,0);
	ObjPrim_SetVertexPosition(magic,3, 128, 128,0);
	ObjPrim_SetVertexUVT(magic,0,  0,  0);
	ObjPrim_SetVertexUVT(magic,1,  0,256);
	ObjPrim_SetVertexUVT(magic,2,256,  0);
	ObjPrim_SetVertexUVT(magic,3,256,256);
	ObjPrim_SetVertexColor(magic,0,R,G,B);
	ObjPrim_SetVertexColor(magic,1,R,G,B);
	ObjPrim_SetVertexColor(magic,2,R,G,B);
	ObjPrim_SetVertexColor(magic,3,R,G,B);

	loop(60) {
		scale2 += 90/60;
		scale3  = 0.90*sin(scale2);
		scale1  = 0.10*sin(scale2);
		anglez  = 360*sin(-scale2);
		anglex  = lean-lean*cos(anglez);
		angley  = lean-lean*sin(anglez);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,anglex,angley,anglez);
		if(direct) { yield; }
	}
	if(!direct) { anglez = GetAreaCommonData("circle","circleanglez",0); scale2 = GetAreaCommonData("circle","circlescale",0); }
	while(!Obj_IsDeleted(enemy)) {
		anglez -= 90/135;
		anglex  = lean-lean*cos(anglez);
		angley  = lean-lean*sin(anglez);

		ObjRender_SetPosition(magic,ObjMove_GetX(enemy),ObjMove_GetY(enemy),0);
		ObjRender_SetScaleXYZ(magic,scale3+scale1,scale3+scale1,1);
		ObjRender_SetAngleXYZ(magic,anglex,angley,anglez);
		SetAreaCommonData("circle","circleanglez",anglez);
		yield;
	}
        Obj_Delete(magic);
}