 
task Shot//メインショットのタスク。
{
let ShotSpeed=18;

let LowDamage=2.0;
let HiDamage=2.0;

loop
{
		if(GetKeyState(VK_SHOT)==KEY_PUSH)
		{
			ShotCountIncrease=9;
		}
		if(ShotCountIncrease>0)
		{
			ShotCountIncrease-=1;
		}
		if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && shotCount==-1 && !OnMissed && GetCommonDataDefault("TitleMenu",false)==false && MissTime==0)
		{
			shotCount = 0;
		}
			if(shotCount%3 == 0)
			{
				if(!OnMissed && GetCommonDataDefault("TitleMenu",false)==false)
				{
					PlaySE(SE[2]);
				}
				if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
				{
					if(BurstLevel==0)
					{
						MarisaMainShot(GetPlayerX+10,GetPlayerY+5,ShotSpeed,270,LowDamage,1);
						MarisaMainShot(GetPlayerX-10,GetPlayerY+5,ShotSpeed,270,LowDamage,1);
					}

					if(BurstLevel==3)
					{
						MarisaMainShot(GetPlayerX+10,GetPlayerY+5,ShotSpeed,270,LowDamage*BL3,3);
						MarisaMainShot(GetPlayerX-10,GetPlayerY+5,ShotSpeed,270,LowDamage*BL3,3);
					}
				}
				else
				{
					if(BurstLevel==0)
					{
						MarisaMainShot(GetPlayerX+10,GetPlayerY+5,ShotSpeed,270,HiDamage,1);
						MarisaMainShot(GetPlayerX-10,GetPlayerY+5,ShotSpeed,270,HiDamage,1);
					}

					if(BurstLevel==3)
					{
						MarisaMainShot(GetPlayerX+10,GetPlayerY+5,ShotSpeed,270,HiDamage*BL3,3);
						MarisaMainShot(GetPlayerX-10,GetPlayerY+5,ShotSpeed,270,HiDamage*BL3,3);
					}
				}
			}
		if(shotCount >= 0)
		{
			shotCount++;
		}

		if(shotCount == 9)
		{
			if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD || ShotCountIncrease>0) && !OnMissed && GetCommonDataDefault("TitleMenu",false)==false)
			{
				shotCount = 0;
			}
			else
			{
				shotCount=-1;
			}
		}
yield;
}
}

task SubShot//オプションからのショット。高速、低速で変化する。
{
let a=10;
let b=5;

let ShotSpeed=18;

let HiDamage=1.075;
let LowDamage=1.0;

let AdjustX=5;
let AdjustY=5;
let Grad=20;
let SlowGrad=8;

loop
{
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
			if(shotCount%3 == 0)
			{
				if(BurstLevel==0)
				{
				MarisaShot(opX[0]-AdjustX*cos(270+SlowGrad),opY[0]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad,HiDamage,1);
				MarisaShot(opX[1]-AdjustX*cos(270+SlowGrad),opY[1]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad,HiDamage,1);
				MarisaShot(opX[2]-AdjustX*cos(270-SlowGrad),opY[2]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad,HiDamage,1);
				MarisaShot(opX[3]-AdjustX*cos(270-SlowGrad),opY[3]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad,HiDamage,1);

				MarisaShot(opX[0]+AdjustX*cos(270+SlowGrad),opY[0]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad+b,HiDamage,1);
				MarisaShot(opX[1]+AdjustX*cos(270+SlowGrad),opY[1]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad+b,HiDamage,1);
				MarisaShot(opX[2]+AdjustX*cos(270-SlowGrad),opY[2]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad-b,HiDamage,1);
				MarisaShot(opX[3]+AdjustX*cos(270-SlowGrad),opY[3]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad-b,HiDamage,1);

				}

				if(BurstLevel==3)
				{
				MarisaShot(opX[0]-AdjustX*cos(270+SlowGrad),opY[0]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad,HiDamage*BL3,3);
				MarisaShot(opX[1]-AdjustX*cos(270+SlowGrad),opY[1]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad,HiDamage*BL3,3);
				MarisaShot(opX[2]-AdjustX*cos(270-SlowGrad),opY[2]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad,HiDamage*BL3,3);
				MarisaShot(opX[3]-AdjustX*cos(270-SlowGrad),opY[3]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad,HiDamage*BL3,3);

				MarisaShot(opX[0]+AdjustX*cos(270+SlowGrad),opY[0]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad+b,HiDamage*BL3,3);
				MarisaShot(opX[1]+AdjustX*cos(270+SlowGrad),opY[1]+AdjustY*sin(270+SlowGrad),ShotSpeed,270-SlowGrad+b,HiDamage*BL3,3);
				MarisaShot(opX[2]+AdjustX*cos(270-SlowGrad),opY[2]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad-b,HiDamage*BL3,3);
				MarisaShot(opX[3]+AdjustX*cos(270-SlowGrad),opY[3]+AdjustY*sin(270+SlowGrad),ShotSpeed,270+SlowGrad-b,HiDamage*BL3,3);
				}
			}
		}
		else
		{
			if(shotCount%3 == 0)
			{
				if(BurstLevel==0)
				{
				MarisaShot(opX[0]-AdjustX*cos(270+Grad),opY[0]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad,HiDamage,1);
				MarisaShot(opX[1]-AdjustX*cos(270+Grad),opY[1]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad,HiDamage,1);
				MarisaShot(opX[2]-AdjustX*cos(270-Grad),opY[2]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad,HiDamage,1);
				MarisaShot(opX[3]-AdjustX*cos(270-Grad),opY[3]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad,HiDamage,1);

				MarisaShot(opX[0]+AdjustX*cos(270+Grad),opY[0]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad+a,HiDamage,1);
				MarisaShot(opX[1]+AdjustX*cos(270+Grad),opY[1]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad+a,HiDamage,1);
				MarisaShot(opX[2]+AdjustX*cos(270-Grad),opY[2]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad-a,HiDamage,1);
				MarisaShot(opX[3]+AdjustX*cos(270-Grad),opY[3]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad-a,HiDamage,1);
				}

				if(BurstLevel==3)
				{
				MarisaShot(opX[0]-AdjustX*cos(270+Grad),opY[0]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad,HiDamage*BL3,3);
				MarisaShot(opX[1]-AdjustX*cos(270+Grad),opY[1]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad,HiDamage*BL3,3);
				MarisaShot(opX[2]-AdjustX*cos(270-Grad),opY[2]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad,HiDamage*BL3,3);
				MarisaShot(opX[3]-AdjustX*cos(270-Grad),opY[3]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad,HiDamage*BL3,3);

				MarisaShot(opX[0]+AdjustX*cos(270+Grad),opY[0]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad+a,HiDamage*BL3,3);
				MarisaShot(opX[1]+AdjustX*cos(270+Grad),opY[1]+AdjustY*sin(270+Grad),ShotSpeed,270-Grad+a,HiDamage*BL3,3);
				MarisaShot(opX[2]+AdjustX*cos(270-Grad),opY[2]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad-a,HiDamage*BL3,3);
				MarisaShot(opX[3]+AdjustX*cos(270-Grad),opY[3]+AdjustY*sin(270+Grad),ShotSpeed,270+Grad-a,HiDamage*BL3,3);
				}
			}
		}
yield;
}
}

task MarisaMainShot(let x,let y,let speed,let angle,let damage,let Type)
{

	let EliminateCount=0;
	let MaxEliminate=5;
	if(BurstMode){MaxEliminate*=2;}

	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,speed);
	Obj_SetAngle(obj,angle);
	ObjShot_SetDamage(obj,damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,Type+1);
	Obj_SetAlpha(obj,100);

	let R;
	let G;
	let B;

	R=127;G=127;B=255;

	if(Type==3)
	{
	R=ColorRed;G=ColorGreen;B=ColorBlue;
	DummyShot(obj,x,y,speed,angle,R,G,B);
	Obj_SetAlpha(obj,0);
	}
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_IsIntersected(obj))
		{
		MainShotHit(Obj_GetX(obj),Obj_GetY(obj));
		if(GetCommonDataDefault("LightMode_ShotEffect",0)==0)
		{
		ShotHit(Obj_GetX(obj)+speed/2*cos(angle),Obj_GetY(obj)+speed/2*sin(angle),angle,2, speed / 6,R,G,B);
		ShotHit(Obj_GetX(obj)+speed*3/2*cos(angle),Obj_GetY(obj)+speed*3/2*sin(angle),angle,2, speed*3 / 6,R,G,B);
		}
		}
		yield;
	}
}


task MarisaShot(let x,let y,let speed,let angle,let damage,let Type)
{
	let EliminateCount=0;
	let MaxEliminate=5;
	if(BurstMode){MaxEliminate*=2;}

	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,speed);
	Obj_SetAngle(obj,angle);
	ObjShot_SetDamage(obj,damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,Type+1);
	Obj_SetAlpha(obj,80);

	let R;
	let G;
	let B;

	R=127;G=127;B=255;

	if(Type==3)
	{
	R=ColorRed;G=ColorGreen;B=ColorBlue;
	DummyShot(obj,x,y,speed,angle,R,G,B);
	Obj_SetAlpha(obj,0);
	}

	ObjShot_SetDamage(obj,damage);

	if(GetCommonDataDefault("LightMode_ShotEffect",0)==0)
	{
	while(!Obj_BeDeleted(obj))
	{
		if(Obj_IsIntersected(obj))
		{
		ShotHit(Obj_GetX(obj)+speed/2*cos(angle),Obj_GetY(obj)+speed/2*sin(angle),angle,2, speed / 6,R,G,B);
		}

		yield;
	}
	}
}

task DummyShot(obj,x,y,speed,angle,R,G,B)
{
	let objE = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(objE, imgShot3);
	ObjEffect_SetPrimitiveType(objE, PRIMITIVE_TRIANGLEFAN);
	Obj_SetPosition(objE,x,y);
	Obj_SetSpeed(objE,speed);
	Obj_SetAngle(objE,angle);
	ObjEffect_CreateVertex(objE, 4);
	ObjEffect_SetRenderState(objE,ADD);
	ObjEffect_SetLayer(objE,2);

	ObjEffect_SetVertexXY(objE, 0, -16, -32);
	ObjEffect_SetVertexXY(objE, 1, 16, -32);
	ObjEffect_SetVertexXY(objE, 2, 16, 32);
	ObjEffect_SetVertexXY(objE, 3, -16, 32);

	ObjEffect_SetVertexUV(objE, 0, 32, 0);
	ObjEffect_SetVertexUV(objE, 1, 64, 0);
	ObjEffect_SetVertexUV(objE, 2, 64, 64);
	ObjEffect_SetVertexUV(objE, 3, 32, 64);
/*
	ObjEffect_SetVertexXY(objE, 0, -4, -32);
	ObjEffect_SetVertexXY(objE, 1, 4, -32);
	ObjEffect_SetVertexXY(objE, 2, 4, 32);
	ObjEffect_SetVertexXY(objE, 3, -4, 32);

	ObjEffect_SetVertexUV(objE, 0, 20, 0);
	ObjEffect_SetVertexUV(objE, 1, 28, 0);
	ObjEffect_SetVertexUV(objE, 2, 28, 64);
	ObjEffect_SetVertexUV(objE, 3, 20, 64);
*/

	ObjEffect_SetScale(objE,1.5,2.0);
	//ObjEffect_SetScale(objE,1.1*2.5,0.8*2.5);
	ObjEffect_SetAngle(objE,0,0,angle+90);

	ascent(i in 0..4)
	{
		ObjEffect_SetVertexColor(objE, i,50, R, G, B);
	}
	while(!Obj_BeDeleted(obj))
	{
		yield;
	}
	Obj_Delete(objE);
}