
task Shot//メインショットのタスク。Powerが低いほど強い。
{
loop
{
		if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && shotCount==-1 && !OnMissed)
		{
			shotCount = 0;
		}
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
			if(shotCount%5 == 0)
			{
				if(!OnMissed)
				{
					PlaySE(SE[2]);
				}
				if(Power<1000)
				{
					MainShotLow(10,8);
					MainShotLow(-10,8);
				}
				if(Power>=1000 && Power<2000)
				{
					MainShotLow(10,7);
					MainShotLow(-10,7);
				}
				if(Power>=2000 && Power<3000)
				{
					MainShotLow(10,6);
					MainShotLow(-10,6);
				}
				if(Power>=3000 && Power<4000)
				{
					MainShotLow(10,5);
					MainShotLow(-10,5);
				}
				if(Power>=4000)
				{
					MainShotLow(10,4);
					MainShotLow(-10,4);
				}
			}
		}
		else
		{
			if(shotCount%5 == 0)
			{
				if(!OnMissed)
				{
					PlaySE(SE[2]);
				}
				if(Power<1000)
				{
					MainShotHi(10,8);
					MainShotHi(-10,8);
				}
				if(Power>=1000 && Power<2000)
				{
					MainShotHi(10,7);
					MainShotHi(-10,7);
				}
				if(Power>=2000 && Power<3000)
				{
					MainShotHi(10,6);
					MainShotHi(-10,6);
				}
				if(Power>=3000 && Power<4000)
				{
					MainShotHi(10,5);
					MainShotHi(-10,5);
				}
				if(Power>=4000)
				{
					MainShotHi(10,4);
					MainShotHi(-10,4);
				}
			}
		}
		if(shotCount >= 0)
		{
			shotCount++;
		}
		if(shotCount == 10)
		{
			shotCount=-1;
		}
yield;
}
}

task MainShotHi(let dx,let damage)
{
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX+dx,GetPlayerY+5);
	Obj_SetSpeed(obj,15);
	Obj_SetAngle(obj,270);
	ObjShot_SetDamage(obj,damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,1);
	Obj_SetAlpha(obj,155);
	if(OnBomb)
	{
		ObjShot_SetDamage(obj,damage/2);
	}
	else
	{
		ObjShot_SetDamage(obj,damage);
	}
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_IsIntersected(obj))
		{
			if(Power<5000)
			{
				Power+=1.50;
			}
		HitMainShotEffect(Obj_GetX(obj),Obj_GetY(obj));
		}
		yield;
	}
}

task MainShotLow(let dx,let damage)
{
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX+dx,GetPlayerY+5);
	Obj_SetSpeed(obj,15);
	Obj_SetAngle(obj,270);
	ObjShot_SetDamage(obj,damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,1);
	Obj_SetAlpha(obj,155);
	if(OnBomb)
	{
		ObjShot_SetDamage(obj,damage/2);
	}
	else
	{
		ObjShot_SetDamage(obj,damage);
	}
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_IsIntersected(obj))
		{
			if(Power<5000)
			{
				Power+=0.75;
			}
		HitMainShotEffect(Obj_GetX(obj),Obj_GetY(obj));
		}
		yield;
	}
}

task HitMainShotEffect(let x,let y)
{
let dy=0;
let speed=7.5;
let alpha=155;
		let scax=1.0;
		let scay=1.0;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgSpell);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -4, -7);
		ObjEffect_SetVertexXY(obj, 1, 4,  -7);
		ObjEffect_SetVertexXY(obj, 2, 4, 7);
		ObjEffect_SetVertexXY(obj, 3,  -4,  7);
		
		ObjEffect_SetVertexUV(obj, 0,  5,  3);
		ObjEffect_SetVertexUV(obj, 1,  14, 3);
		ObjEffect_SetVertexUV(obj, 2, 14,  17);
		ObjEffect_SetVertexUV(obj, 3, 5, 17);

		ObjEffect_SetVertexColor(obj,0,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,1,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,2,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,3,alpha,255,255,255);

		Obj_SetPosition(obj,x,y);
		loop(10)
		{
		scax-=0.1;
		scay-=0.1;
		Obj_SetPosition(obj,x,y-dy);
		ObjEffect_SetScale(obj, scax,scay);
		dy+=speed;
		yield;
		}
		Obj_Delete(obj);
}