
task StreamLaser(SET_KEY)
{
	if(IsPermitPlayerShot==false){return;}

	let speed=0;
	let angle=CharaDirection*45-90;
	let damage=Status_MagicPower*0.35;
	let type=1000;
	if(IsPermitPlayerShot==false){return;}
	if(GetCommonData("SceneChange",false)==true){return;}

	if(SpiritPoint>=1*SpiritReduce)
	{
		SpiritPoint-=1*SpiritReduce;
	}
	else
	{
		SpiritPointLack;
		return;
	}

	Obj_PlaySE(GetCurrentScriptDirectory~"../se/tama1.wav");

	let objShot = ObjShot_Create(OBJ_STRAIGHT_LASER);
	ObjMove_SetX(objShot, GetPlayerX);//x座標設定
	ObjMove_SetY(objShot, GetPlayerY);//y座標設定;
	ObjMove_SetSpeed(objShot, speed);//速度設定
	ObjMove_SetAngle(objShot, angle);
	ObjStLaser_SetAngle(objShot, angle);
	ObjShot_SetGraphic(objShot, type);//画像設定
	ObjShot_SetDamage(objShot, damage);//ダメージを設定
	ObjShot_SetPenetration(objShot, 10000);//貫通力は適当に大きく
	ObjShot_Regist(objShot);

	ObjLaser_SetLength(objShot,800);
	ObjLaser_SetInvalidLength(objShot,0,0);
	ObjLaser_SetRenderWidth(objShot,20);

	let ShotCount=0;
	HitEffect;
	while(GetVirtualKeyState(SET_KEY)==KEY_PUSH || GetVirtualKeyState(SET_KEY)==KEY_HOLD)
	{
		if(angle!=CharaDirection*45-90){break;}
		if(SpiritPoint>=0.12*SpiritReduce)
		{
			SpiritPoint-=0.12*SpiritReduce;
		}
		else
		{
			SpiritPointLack;
			break;
		}
		ShotForbitTime(5);
		if(ShotCount%5==0)
		{ObjShot_SetDamage(objShot, damage);}
		else{ObjShot_SetDamage(objShot, 0);}
	//	ObjStLaser_SetAngle(objShot, angle);
		ObjMove_SetX(objShot, GetPlayerX);//x座標設定
		ObjMove_SetY(objShot, GetPlayerY);//y座標設定;
		ShotCount+=1;
		yield;
	}
	Obj_Delete(objShot);

	task HitEffect
	{
	let img = GetCurrentScriptDirectory() ~ "../img/dot_marisa1.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetTexture(obj, img);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjPrim_SetVertexCount(obj, 4);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj,35);
	ObjRender_SetAngleZ(obj,0);

	ObjPrim_SetVertexPosition(obj, 0, 0, -5, 0);
	ObjPrim_SetVertexPosition(obj, 1, 800, -5, 0);
	ObjPrim_SetVertexPosition(obj, 2, 800, 5, 0);
	ObjPrim_SetVertexPosition(obj, 3,0, 5, 0);

	ObjPrim_SetVertexUVT(obj, 0, 35, 5);
	ObjPrim_SetVertexUVT(obj, 1, 45, 5);
	ObjPrim_SetVertexUVT(obj, 2, 45, 25);
	ObjPrim_SetVertexUVT(obj, 3, 35, 25);

	let Scale=1.0;

	let Zangle=angle+90;

	ObjRender_SetPosition(obj,GetPlayerX,GetPlayerY,0);

	ObjRender_SetScaleXYZ(obj,1,1,1,);
	let Alpha=1;
	ObjRender_SetColor(obj,128*Alpha,255*Alpha,128*Alpha);

	while(!Obj_IsDeleted(objShot))
	{
		HitEffectShadow(GetPlayerX+10*cos(angle),GetPlayerY+10*sin(angle),angle);
		ObjRender_SetColor(obj,96*Alpha,255*Alpha,128*Alpha);
		ObjRender_SetAngleZ(obj,angle);
		ObjRender_SetX(obj, GetPlayerX+10*cos(angle));//x座標設定
		ObjRender_SetY(obj, GetPlayerY+10*sin(angle));//y座標設定;
		yield;
	}
	Obj_Delete(obj);

	}

	task HitEffectShadow(x,y,angle)
	{
	let img = GetCurrentScriptDirectory() ~ "../img/dot_marisa1.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetTexture(obj, img);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjPrim_SetVertexCount(obj, 4);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriorityI(obj,30);
	ObjRender_SetAngleZ(obj,0);

	ObjPrim_SetVertexPosition(obj, 0, 0, rand(-4,-6), 0);
	ObjPrim_SetVertexPosition(obj, 1, 800, rand(-4,-6), 0);
	ObjPrim_SetVertexPosition(obj, 2, 800, rand(4,6), 0);
	ObjPrim_SetVertexPosition(obj, 3,0, rand(4,6), 0);

	ObjPrim_SetVertexUVT(obj, 0, 12, 17);
	ObjPrim_SetVertexUVT(obj, 1, 19, 17);
	ObjPrim_SetVertexUVT(obj, 2, 19, 20);
	ObjPrim_SetVertexUVT(obj, 3, 12, 20);

	let Scale=1.0;

	let Zangle=angle+90;

	ObjRender_SetPosition(obj,x,y,0);

	ObjRender_SetScaleXYZ(obj,1,1.0,1,);
	let Alpha=0.25;
	ObjRender_SetColor(obj,128*Alpha,255*Alpha,128*Alpha);
	let ox=ObjRender_GetX(obj);
	let oy=ObjRender_GetY(obj);
	loop(10)
	{	if(Obj_IsDeleted(objShot)){break;}
		let sr=Obj_GetValue(GetPlayerObjectID,"Move_Right");
		let sl=Obj_GetValue(GetPlayerObjectID,"Move_Left");
		let su=Obj_GetValue(GetPlayerObjectID,"Move_Up");
		let sd=Obj_GetValue(GetPlayerObjectID,"Move_Down");
		if(sr!=0)
		{
			ObjRender_SetX(obj, ObjRender_GetX(obj)-sr);
		}
		if(sl!=0)
		{
			ObjRender_SetX(obj, ObjRender_GetX(obj)-sl);
		}
		if(su!=0)
		{
			ObjRender_SetY(obj, ObjRender_GetY(obj)-su);
		}
		if(sd!=0)
		{
			ObjRender_SetY(obj, ObjRender_GetY(obj)-sd);
		}

		ObjRender_SetColor(obj,128*Alpha,255*Alpha,128*Alpha);
		ObjRender_SetAngleZ(obj,angle);
		Alpha-=0.25/10;
		if(ox==ObjRender_GetX(obj) || oy==ObjRender_GetY(obj))
		{
		Alpha-=0.25/10;
		}
		ox=ObjRender_GetX(obj);
		oy=ObjRender_GetY(obj);
		yield;
		
	}
	Obj_Delete(obj);

	}
}
