 
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)
		{
			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 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;

	alternative(Type)
	case(0){R=127;G=255;B=127;}
	case(1){R=127;G=127;B=255;}
	case(2){R=255;G=64;B=64;}
	case(3){R=ColorRed;G=ColorGreen;B=ColorBlue;}

	if(Type==3)
	{
	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);
		}
		}
		yield;
	}
}

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

	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;

	alternative(Type)
	case(0){R=127;G=255;B=127;}
	case(1){R=127;G=127;B=255;}
	case(2){R=255;G=64;B=64;}
	case(3){R=ColorRed;G=ColorGreen;B=ColorBlue;}

	if(Type==3)
	{
	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);
			}
		}
		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);
}

task ShotHit(let x, let y, let angle, let vang, let speed,R,G,B)
{
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, imgShot3);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetLayer(obj,2);
	
	ObjEffect_SetVertexXY(obj, 0, -8, -32);
	ObjEffect_SetVertexXY(obj, 1, 8, -32);
	ObjEffect_SetVertexXY(obj, 2, 8, 32);
	ObjEffect_SetVertexXY(obj, 3, -8, 32);

	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 16, 0);
	ObjEffect_SetVertexUV(obj, 2, 16, 64);
	ObjEffect_SetVertexUV(obj, 3, 0, 64);

	ObjEffect_SetAngle(obj,0,0,angle+90);

	let Alpha = 200;
	let count = 0;
	while(Alpha > 0)
	{
		Obj_SetPosition(obj, x+speed*count*cos(angle), y+speed*count*sin(angle));
		Alpha-=20;
		count++;
		yield;
		ascent(i in 0..4){ObjEffect_SetVertexColor(obj, i, Alpha,R,G,B);}
	}
	Obj_Delete(obj);
}
