#東方弾幕風[Player]
#ScriptVersion[2]
#Menu[博麗霊夢A]
#Text[パスウェイジョンニードル 

	夢符「封魔陣」
	夢符「退魔符乱舞」

	特性　喰らいボム受付時間が長め]
#ReplayName[霊夢A]

script_player_main
{
	let count=0;
	let Power=2000;		//Power管理変数
	let drawangle=0;	//オプションの回転角度
	let opX=[0,1,2,3,4,5];	//オプションのX座標
	let opY=[0,1,2,3,4,5];	//オプションのY座標
	let csd = GetCurrentScriptDirectory();
	let img = csd~"..\img\player_reimu.png";
	let imgSpell = csd~"..\img\HoshiShot.png";
	let imgKekkai = csd~"..\img\circle.png";
	let imgBorder = csd~"..\img\border.png";
	let imgShot = csd~"..\img\shot_all.png";
	let shotCount = -1;
	let KekkaiOn=0;	//結界が発動中かどうかの変数
	let Kekkaicount=0;//結界が張れるようになるまでの時間
	let bonus=1;	//結界収縮用変数
	let bonuspoint=0;
	let BombBonus=0;
	let miss=0;
	SetCommonData("STARTPOWER",0);

	@Initialize
	{
	//	SetAutoEffect(false);
		SetPlayerLifeImage(img, 0, 0, 48, 48);
		LoadGraphic(img);
		LoadGraphic(imgSpell);
		LoadGraphic(imgKekkai);
		LoadGraphic(imgBorder);
		LoadGraphic(csd~"..\img\shot_reimu.png");
		LoadGraphic(imgShot);
		SetSpeed(4.5, 2.0);//自機の移動速度
		LoadPlayerShotData(csd~"..\txt\ShotData.txt");
		SetItemCollectLine(160);//アイテム回収されるy座標
		SetGrazeCircle(45);//自機のかすり判定
		SetRebirthFrame(12);//食らいボムの有効フレーム
		Tmain;
	}

	task Tmain
	{
		yield;
		Cdraw;
		Pdraw;
		optionmove;
		Powor;
		GetPowerItem;
		GetBonusItem;
		Shot;
		SubShot;
		Graze;
		Bdraw;
	//	Invincibility;
	}

	@MainLoop
	{
		SetIntersectionCircle(GetPlayerX, GetPlayerY, 0);//自機の当たり判定
		if(GetKeyState(VK_BOMB)==KEY_PUSH &&  GetPlayerBomb==0 && BombBonus>=2 && !OnMissed)
		{
			BombBonus-=2;
			SetCommonData("BombBonus",BombBonus);
			AddBomb(1);
		}
		if(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD || GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
			SetGrazeCircle(45);
		}
		else
		{
			SetGrazeCircle(55);
		}
		yield;
	}

	@Missed{
MainLoop;
if(OnBorderOfLife && KekkaiOn==1)//バリア中はオートボム
{
	KekkaiOn=0;
	bonus=0;
	if(GetPlayerBomb>=1)
	{
	CallSpellCard;
	}

}
else if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="Extra")//Exはオートボム
{
	if(GetPlayerBomb>=1)
	{
	heat+=2000;
	CallSpellCard;
	}
}

}

	@SpellCard//バリアの有無によってボム変化
	{
			if(KekkaiOn==0)
			{
			UseSpellCard("Huumajin", 0);
			}
			else
			{
			UseSpellCard("TaimahuRanbu", 0);
			}
		bonus=0;
		KekkaiOn=0;

	}

	@DrawLoop
	{
		if(GetTimeOfPlayerInvincibility>0)
		{
			SetColor(100, 100, 255);
		}
		else
		{
			SetColor(255, 255, 255);
		}
		SetGraphicAngle(0,0,0);
		SetRenderState(ALPHA);

		SetTexture(img);
		if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			if(GetCommonDataDefault("MoveReverse",false)==true && OnEnemySpell)
			{
				SetGraphicRect(10, 101, 38, 142);
			}
			else
			{
				SetGraphicRect(10, 53, 38, 94);
			}

		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			if(GetCommonDataDefault("MoveReverse",false)==true && OnEnemySpell)
			{
				SetGraphicRect(10, 53, 38, 94);
			}
			else
			{
				SetGraphicRect(10, 101, 38, 142);
			}
		}
		else
		{

			SetGraphicRect(10, 6, 38, 48);


		}
		DrawGraphic(GetPlayerX(), GetPlayerY());//自機の描画


		if(Power>=5000)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle+180);
		SetAlpha(150);
		SetGraphicScale(1.4,1.4);
        	DrawGraphic(opX[0], opY[0]);
        	DrawGraphic(opX[1], opY[1]);
        	DrawGraphic(opX[2], opY[2]);
        	DrawGraphic(opX[3], opY[3]);
		}


		if(Power>=0)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[0], opY[0]);
		}

		if(Power>=0)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[1], opY[1]);
		}

		if(Power>=0)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[2], opY[2]);
		}

		if(Power>=0)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[3], opY[3]);
		}
		drawangle+=6;//オプションの描画


	/*	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
		SetTexture(imgBorder);
		SetGraphicRect(27,27,37,37);
		SetGraphicAngle(0,0,drawangle/4);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(GetPlayerX(), GetPlayerY());
		}
	*/	atari;
	}

	@Finalize
	{
		DeleteGraphic(img);
		DeleteGraphic(imgSpell);
		DeleteGraphic(imgKekkai);
		DeleteGraphic(imgBorder);
	}



task Invincibility
{
let Invinangle=0;
loop
{
		Invinangle+=3;
		let scax=GetTimeOfPlayerInvincibility/180;
		let scay=GetTimeOfPlayerInvincibility/180;
  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgShot);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		//ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -32, -32);
		ObjEffect_SetVertexXY(obj, 1,  32, -32);
		ObjEffect_SetVertexXY(obj, 2,  32,  32);
		ObjEffect_SetVertexXY(obj, 3, -32,  32);
		
		ObjEffect_SetVertexUV(obj, 0,  414,  352);
		ObjEffect_SetVertexUV(obj, 1,  478, 352);
		ObjEffect_SetVertexUV(obj, 2, 478,  416);
		ObjEffect_SetVertexUV(obj, 3, 414, 416);

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

		
		ObjEffect_SetLayer(obj, 1);
		ObjEffect_SetAngle(obj, 0,0,Invinangle);
		ObjEffect_SetScale(obj, scax,scay);
		yield;
		Obj_Delete(obj);
}
}

#include_script".\..\txt\Pdraw.txt"
#include_script".\..\txt\Bdraw.txt"
#include_script".\..\txt\Cdraw.txt"
#include_script".\..\txt\Power.txt"
#include_script".\..\txt\Graze.txt"
#include_script".\ReimuMainShot.txt"
#include_script".\ReimuSubShot.txt"
#include_script".\ReimuOptionMove.txt"

#include_script".\..\txt\data.txt"
}

#include_script".\..\txt\Spell001.txt"
