
let EnableAngle=0;
task Pdraw(Cobj)//装填率と可能、不可能を表示するタスク
{
		let obj2 = Obj_Create(OBJ_EFFECT);
		let obj3 = Obj_Create(OBJ_EFFECT);
		let obj5 = Obj_Create(OBJ_EFFECT);
		let obj4 = Obj_Create(OBJ_EFFECT);
		let obj6 = Obj_Create(OBJ_EFFECT);
loop{
let Pnum1=truncate(Charge%10000/1000);
let Pnum2=truncate(Charge%1000/100);
let Pnum3=truncate(Charge%100/10);
let Pnum4=truncate(Charge%10);
EnableAngle+=5;

		ObjEffect_SetTexture(obj2, imgBorder);
		ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj2, ADD); 
		ObjEffect_CreateVertex(obj2, 4);
		ObjEffect_SetVertexXY(obj2, 0, -7, -8);
		ObjEffect_SetVertexXY(obj2, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj2, 2, 7, 8);
		ObjEffect_SetVertexXY(obj2, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj2, 0,  2+Pnum2*14,  114);
		ObjEffect_SetVertexUV(obj2, 1,  14+Pnum2*14, 114);
		ObjEffect_SetVertexUV(obj2, 2, 14+Pnum2*14,  131);
		ObjEffect_SetVertexUV(obj2, 3, 2+Pnum2*14, 131);
		
		Obj_SetPosition(obj2,Obj_GetX(Cobj)-30,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj2,3);
		ObjEffect_SetScale(obj2, 0.4,0.5);

////////////////////////////////////////////////////////////////////////////////////
		ObjEffect_SetTexture(obj3, imgBorder);
		ObjEffect_SetPrimitiveType(obj3, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj3, ADD); 
		ObjEffect_CreateVertex(obj3, 4);
		ObjEffect_SetVertexXY(obj3, 0, -7, -8);
		ObjEffect_SetVertexXY(obj3, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj3, 2, 7, 8);
		ObjEffect_SetVertexXY(obj3, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj3, 0,  2+Pnum3*14,  114);
		ObjEffect_SetVertexUV(obj3, 1,  14+Pnum3*14, 114);
		ObjEffect_SetVertexUV(obj3, 2, 14+Pnum3*14,  131);
		ObjEffect_SetVertexUV(obj3, 3, 2+Pnum3*14, 131);
		
		Obj_SetPosition(obj3,Obj_GetX(Cobj)-22,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj3,3);
		ObjEffect_SetScale(obj3, 0.4,0.5);
///////////////////////////////////////////////////////////////////////////////////////
		ObjEffect_SetTexture(obj5, imgBorder);
		ObjEffect_SetPrimitiveType(obj5, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj5, ADD); 
		ObjEffect_CreateVertex(obj5, 4);
		ObjEffect_SetVertexXY(obj5, 0, -7, -8);
		ObjEffect_SetVertexXY(obj5, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj5, 2, 7, 8);
		ObjEffect_SetVertexXY(obj5, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj5, 0,  2+Pnum4*14,  114);
		ObjEffect_SetVertexUV(obj5, 1,  14+Pnum4*14, 114);
		ObjEffect_SetVertexUV(obj5, 2, 14+Pnum4*14,  131);
		ObjEffect_SetVertexUV(obj5, 3, 2+Pnum4*14, 131);
		
		Obj_SetPosition(obj5,Obj_GetX(Cobj)-14,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj5,3);
		ObjEffect_SetScale(obj5, 0.4,0.5);
//////////////////////////////////////////////////////////////////////////////////////////

		ObjEffect_SetTexture(obj4, imgBorder);
		ObjEffect_SetPrimitiveType(obj4, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj4, ADD); 
		ObjEffect_CreateVertex(obj4, 4);

		ObjEffect_SetVertexXY(obj4, 0, -8, -8);
		ObjEffect_SetVertexXY(obj4, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj4, 2, 8, 8);
		ObjEffect_SetVertexXY(obj4, 3,  -8,  8);
		
		ObjEffect_SetVertexUV(obj4, 0,  149,  114);
		ObjEffect_SetVertexUV(obj4, 1,  165, 114);
		ObjEffect_SetVertexUV(obj4, 2, 165,  129);
		ObjEffect_SetVertexUV(obj4, 3, 149, 129);
		
		Obj_SetPosition(obj4,Obj_GetX(Cobj)-6,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj4,3);
		ObjEffect_SetScale(obj4, 0.4,0.5);
//////////////////////////////////////////////////////////////////////////////////////

		ObjEffect_SetTexture(obj6, imgBorder);
		ObjEffect_SetPrimitiveType(obj6, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj6, ADD); 
		ObjEffect_CreateVertex(obj6, 4);
		if(Charge==100)
		{
		ObjEffect_SetVertexXY(obj6, 0, -30, -8);
		ObjEffect_SetVertexXY(obj6, 1, 30,  -8);
		ObjEffect_SetVertexXY(obj6, 2, 30, 8);
		ObjEffect_SetVertexXY(obj6, 3,  -30,  8);
		
		ObjEffect_SetVertexUV(obj6, 0,  74,  139);
		ObjEffect_SetVertexUV(obj6, 1,  134, 139);
		ObjEffect_SetVertexUV(obj6, 2, 134,  155);
		ObjEffect_SetVertexUV(obj6, 3, 74, 155);
		}
		else
		{
		ObjEffect_SetVertexXY(obj6, 0, -33, -8);
		ObjEffect_SetVertexXY(obj6, 1, 33,  -8);
		ObjEffect_SetVertexXY(obj6, 2, 33, 8);
		ObjEffect_SetVertexXY(obj6, 3,  -33,  8);
		
		ObjEffect_SetVertexUV(obj6, 0,  0,  139);
		ObjEffect_SetVertexUV(obj6, 1,  66, 139);
		ObjEffect_SetVertexUV(obj6, 2, 66,  155);
		ObjEffect_SetVertexUV(obj6, 3, 0, 155);
		}		
		Obj_SetPosition(obj6,Obj_GetX(Cobj)+27,Obj_GetY(Cobj)+8);
		ObjEffect_SetLayer(obj6,3);
		ObjEffect_SetScale(obj6, 0.8,0.5);

		if(FinderMode==true)
		{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj6,i,0,255,255,255);
				ObjEffect_SetVertexColor(obj2,i,0,255,255,255);
				ObjEffect_SetVertexColor(obj3,i,0,255,255,255);
				ObjEffect_SetVertexColor(obj4,i,0,255,255,255);
				ObjEffect_SetVertexColor(obj5,i,0,255,255,255);
			}
		}
		else
		{
			if(Charge==100)
			{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj2,i,120,255,200,200);
				ObjEffect_SetVertexColor(obj3,i,120,255,200,200);
				ObjEffect_SetVertexColor(obj4,i,120,255,200,200);
				ObjEffect_SetVertexColor(obj5,i,120,255,200,200);
				ObjEffect_SetVertexColor(obj6,i,100+25*cos(EnableAngle),255,200,200);
			}	
			}
			else
			{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj2,i,120,255,255,255);
				ObjEffect_SetVertexColor(obj3,i,120,255,255,255);
				ObjEffect_SetVertexColor(obj4,i,120,255,255,255);
				ObjEffect_SetVertexColor(obj5,i,120,255,255,255);
				ObjEffect_SetVertexColor(obj6,i,100+25*cos(EnableAngle),255,255,255);
			}	
			}
		}
///////////////////////////////////////////////////////////////////////////////////////
		wait(1);
	//	Obj_Delete(obj2);
	//	Obj_Delete(obj3);
	//	Obj_Delete(obj4);
	//	Obj_Delete(obj5);
	//	Obj_Delete(obj6);
}
}

////////////////////////////////////////////////////////////////////////////////////

task FinderPdraw(Cobj)//ファインダーモード時残り時間％で表示するをタスク
{
		let obj2 = Obj_Create(OBJ_EFFECT);
		let obj3 = Obj_Create(OBJ_EFFECT);
		let obj5 = Obj_Create(OBJ_EFFECT);
		let obj4 = Obj_Create(OBJ_EFFECT);
loop{
let Pnum1=truncate(Charge%10000/1000);
let Pnum2=truncate(Charge%1000/100);
let Pnum3=truncate(Charge%100/10);
let Pnum4=truncate(Charge%10);
EnableAngle+=5;

		ObjEffect_SetTexture(obj2, imgBorder);
		ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj2, ADD); 
		ObjEffect_CreateVertex(obj2, 4);
		ObjEffect_SetVertexXY(obj2, 0, -7, -8);
		ObjEffect_SetVertexXY(obj2, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj2, 2, 7, 8);
		ObjEffect_SetVertexXY(obj2, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj2, 0,  2+Pnum2*14,  114);
		ObjEffect_SetVertexUV(obj2, 1,  14+Pnum2*14, 114);
		ObjEffect_SetVertexUV(obj2, 2, 14+Pnum2*14,  131);
		ObjEffect_SetVertexUV(obj2, 3, 2+Pnum2*14, 131);
		
		Obj_SetPosition(obj2,Obj_GetX(Cobj)-30,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj2,3);
		ObjEffect_SetScale(obj2, 0.4,0.5);

////////////////////////////////////////////////////////////////////////////////////

		ObjEffect_SetTexture(obj3, imgBorder);
		ObjEffect_SetPrimitiveType(obj3, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj3, ADD); 
		ObjEffect_CreateVertex(obj3, 4);
		ObjEffect_SetVertexXY(obj3, 0, -7, -8);
		ObjEffect_SetVertexXY(obj3, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj3, 2, 7, 8);
		ObjEffect_SetVertexXY(obj3, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj3, 0,  2+Pnum3*14,  114);
		ObjEffect_SetVertexUV(obj3, 1,  14+Pnum3*14, 114);
		ObjEffect_SetVertexUV(obj3, 2, 14+Pnum3*14,  131);
		ObjEffect_SetVertexUV(obj3, 3, 2+Pnum3*14, 131);
		
		Obj_SetPosition(obj3,Obj_GetX(Cobj)-22,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj3,3);
		ObjEffect_SetScale(obj3, 0.4,0.5);
///////////////////////////////////////////////////////////////////////////////////////

		ObjEffect_SetTexture(obj5, imgBorder);
		ObjEffect_SetPrimitiveType(obj5, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj5, ADD); 
		ObjEffect_CreateVertex(obj5, 4);
		ObjEffect_SetVertexXY(obj5, 0, -7, -8);
		ObjEffect_SetVertexXY(obj5, 1, 7,  -8);
		ObjEffect_SetVertexXY(obj5, 2, 7, 8);
		ObjEffect_SetVertexXY(obj5, 3,  -7,  8);
		
		ObjEffect_SetVertexUV(obj5, 0,  2+Pnum4*14,  114);
		ObjEffect_SetVertexUV(obj5, 1,  14+Pnum4*14, 114);
		ObjEffect_SetVertexUV(obj5, 2, 14+Pnum4*14,  131);
		ObjEffect_SetVertexUV(obj5, 3, 2+Pnum4*14, 131);
		
		Obj_SetPosition(obj5,Obj_GetX(Cobj)-14,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj5,3);
		ObjEffect_SetScale(obj5, 0.4,0.5);
//////////////////////////////////////////////////////////////////////////////////////////

		ObjEffect_SetTexture(obj4, imgBorder);
		ObjEffect_SetPrimitiveType(obj4, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj4, ADD); 
		ObjEffect_CreateVertex(obj4, 4);

		ObjEffect_SetVertexXY(obj4, 0, -8, -8);
		ObjEffect_SetVertexXY(obj4, 1, 8,  -8);
		ObjEffect_SetVertexXY(obj4, 2, 8, 8);
		ObjEffect_SetVertexXY(obj4, 3,  -8,  8);
		
		ObjEffect_SetVertexUV(obj4, 0,  149,  114);
		ObjEffect_SetVertexUV(obj4, 1,  165, 114);
		ObjEffect_SetVertexUV(obj4, 2, 165,  129);
		ObjEffect_SetVertexUV(obj4, 3, 149, 129);
		
		Obj_SetPosition(obj4,Obj_GetX(Cobj)-6,Obj_GetY(Cobj)-10);
		ObjEffect_SetLayer(obj4,3);
		ObjEffect_SetScale(obj4, 0.4,0.5);


		if(FinderMode==false || GetCommonDataDefault("Shooting",false)==true)
		{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj2,i,0,200,255,200);
				ObjEffect_SetVertexColor(obj3,i,0,200,255,200);
				ObjEffect_SetVertexColor(obj4,i,0,200,255,200);
				ObjEffect_SetVertexColor(obj5,i,0,200,255,200);
			}
		}
		else
		{
			if(Charge==100)
			{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj2,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj3,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj4,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj5,i,150,200,255,200);
			}	
			}
			else
			{
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj2,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj3,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj4,i,150,200,255,200);
				ObjEffect_SetVertexColor(obj5,i,150,200,255,200);
			}	
			}
			if(GetKeyState(VK_SHOT)==KEY_PULL)
			{
				Obj_Delete(obj2);
				Obj_Delete(obj3);
				Obj_Delete(obj4);
				Obj_Delete(obj5);
			}
		}
///////////////////////////////////////////////////////////////////////////////////////
		wait(1);
	//	Obj_Delete(obj2);
	//	Obj_Delete(obj3);
	//	Obj_Delete(obj4);
	//	Obj_Delete(obj5);
}
}