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

let Damage=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(BurstLevel==0)
				{
					MarisaMainShot(GetPlayerX+10,GetPlayerY+5,ShotSpeed,270,Damage,2);
					MarisaMainShot(GetPlayerX-10,GetPlayerY+5,ShotSpeed,270,Damage,2);
				}

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

		if(shotCount == 12)
		{
			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=7.5;

let ShotSpeed=18;

let HiDamage=1.00;
let LowDamage=1.00;

let AdjustX=5;
let AdjustY=-5;
let Grad=10;

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

				MarisaShot(opX[0]+AdjustX,opY[0]+AdjustY,ShotSpeed,270,LowDamage,2,0);
				MarisaShot(opX[1]+AdjustX,opY[1]+AdjustY,ShotSpeed,270,LowDamage,2,1);
				MarisaShot(opX[2]+AdjustX,opY[2]+AdjustY,ShotSpeed,270,LowDamage,2,2);
				MarisaShot(opX[3]+AdjustX,opY[3]+AdjustY,ShotSpeed,270,LowDamage,2,3);


				}

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

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

				MarisaShot(opX[0]+AdjustX,opY[0]+AdjustY,ShotSpeed,270,LowDamage,2,0);
				MarisaShot(opX[1]+AdjustX,opY[1]+AdjustY,ShotSpeed,270,LowDamage,2,1);
				MarisaShot(opX[2]+AdjustX,opY[2]+AdjustY,ShotSpeed,270,LowDamage,2,2);
				MarisaShot(opX[3]+AdjustX,opY[3]+AdjustY,ShotSpeed,270,LowDamage,2,3);

				}

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

				MarisaShot(opX[0]+AdjustX,opY[0]+AdjustY,ShotSpeed,270,LowDamage*BL3,3,0);
				MarisaShot(opX[1]+AdjustX,opY[1]+AdjustY,ShotSpeed,270,LowDamage*BL3,3,1);
				MarisaShot(opX[2]+AdjustX,opY[2]+AdjustY,ShotSpeed,270,LowDamage*BL3,3,2);
				MarisaShot(opX[3]+AdjustX,opY[3]+AdjustY,ShotSpeed,270,LowDamage*BL3,3,3);
				}
			}
		}
yield;
}
}

task MarisaMainShot(let x,let y,let speed,let angle,let damage,let Type)
{
	let EliminateCount=0;
	let MaxEliminate=5;
	let EliminateCircle=2+EliminateIntensity/50;

	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=255;G=64;B=64;

	if(Type==3)
	{
	R=ColorRed;G=ColorGreen;B=ColorBlue;
	DummyMainShot(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);
		}
		}
		if(EliminateMode)
		{
		if(GetEnemyShotCountEx(Obj_GetX(obj),Obj_GetY(obj),EliminateCircle,ALL)>0)
		{
			DeleteEnemyShotImmediatelyInCircle(SHOT,Obj_GetX(obj),Obj_GetY(obj),EliminateCircle);
			CreateMigicItem(Obj_GetX(obj),Obj_GetY(obj),8);
			EliminateCount+=1;
			if(EliminateCount>=MaxEliminate)
			{
			Obj_Delete(obj);
			}
		}
		}
		yield;
	}
}

task MarisaShot(let x,let y,let speed,let angle,let damage,let Type,let OpNum)
{
	let EliminateCount=0;
	let MaxEliminate=5;
	let EliminateCircle=1+EliminateIntensity/100;

	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=255;G=64;B=64;

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

	while(!Obj_BeDeleted(obj))
	{

	Obj_SetX(obj,opX[OpNum]);
		if(Obj_IsIntersected(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);
			}
		}
		/*
		if(EliminateMode)
		{
		if(GetEnemyShotCountEx(Obj_GetX(obj),Obj_GetY(obj),EliminateCircle,ALL)>0)
		{
			DeleteEnemyShotImmediatelyInCircle(SHOT,Obj_GetX(obj),Obj_GetY(obj),EliminateCircle);
			CreateMigicItem(Obj_GetX(obj),Obj_GetY(obj),8);
			EliminateCount+=1;
			if(EliminateCount>=MaxEliminate)
			{
			Obj_Delete(obj);
			}
		}
		}
		*/
		yield;
	}
}

task DummyMainShot(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, -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_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_SetScale(objE,1.1*2.5,0.8*2.5);
	ObjEffect_SetScale(objE,1.5,1.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);
}

task DummyShot(obj,x,y,speed,angle,R,G,B,OpNum)
{
	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, -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_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_SetScale(objE,1.1*2.5,0.8*2.5);
	ObjEffect_SetScale(objE,1.5,1.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))
	{
		Obj_SetX(objE,opX[OpNum]);
		yield;
	}
	Obj_Delete(objE);
}

