#e[Player]
#ScriptVersion[2]
#Menu[얲A]
#Text[pXEFCWj[h 

	uwv
	uޖv

	@炢{tԂ]
#ReplayName[얲A]

script_player_main
{
	let count=0;
	let Power=2000;		//PowerǗϐ
	let drawangle=0;	//IvV̉]px
	let opX=[0,1,2,3,4,5];	//IvVXW
	let opY=[0,1,2,3,4,5];	//IvVYW
	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;	//Eǂ̕ϐ
	let Kekkaicount=0;//E悤ɂȂ܂ł̎
	let bonus=1;	//Ekpϐ
	let BonusOn=-1;
	let bonuspoint=0;
	let BombBonus=0;
	let miss=0;
	SetCommonData("STARTPOWER",0);
	let SE=["seSuperNaturalBorder1.wav","seSuperNaturalBorder2.wav","sePlayerShot01.wav"];
	@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);//@̈ړx
		LoadPlayerShotData(csd~"..\txt\ShotData.txt");
		SetItemCollectLine(160);//ACeyW
		SetGrazeCircle(45);//@̂蔻
		SetRebirthFrame(12);//H炢{̗Lt[
		Config;
		Tmain;
	}

	task Tmain
	{
		yield;
		Cdraw;
		Pdraw;
		optionmove;
		Powor;
		GetPowerItem;
		GetBonusItem;
		Shot;
		SubShot;
		if(BonusOn==1)
		{
		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)//oA̓I[g{
{
	KekkaiOn=0;
	bonus=0;
	if(GetPlayerBomb>=1)
	{
	CallSpellCard;
	}

}
       SetPlayerInvincibility(250);
}

	@SpellCard//oA̗Lɂă{ω
	{
			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>=1000)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[0], opY[0]);
		}

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

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

		if(Power>=4000)
		{
		SetGraphicRect(21,162,35,176);
		SetGraphicAngle(0,0,drawangle);
		SetAlpha(255);
		SetGraphicScale(1.0,1.0);
        	DrawGraphic(opX[3], opY[3]);
		}
		drawangle+=6;//IvV̕`


		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());
		}

	}

	@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"

task Config
{
#include_script".\..\txt\config.txt"
}

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

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