#e[Player]
#ScriptVersion[2]
#Menu[_   iAR v2.0]
#Text[]

#Image[.\img\Yukari_select.png]
#Replayname[Yukari]

script_player_main{


#include_function".\teamBorder_Setting.txt";

let n_PX = 0;
let n_PY = 0;

let an_MoveSpeed = [ n_YukariSpeed01, n_YukariSpeed02 ];

//f[^t@Cw============================
let current = GetCurrentScriptDirectory();
let img_Human = current~"img\Reimu.png";
let img_Yokai = current~"img\Yukari.png";
let img_System = current~"img\System.png";
let img_Char = current~"img\Char.png";
let img_BOL = current~"img\BOL.png";
let img_Shot = current~"img\bullet.png";

let img_YukariSpell = current~"img\YukariSpell.png";
let img_Border = current~"img\border.png";

let se_Shot = current~"se\sha04+.wav";
let se_Chip = current~"se\on01+.wav";
let se_Shift = current~"se\power32+.wav";

//O[oϐ̒`============================
let NEUTRAL = -1;			//
let HUMAN = 0;				// 񋓎q
let YOKAI = 1;				//

let e_CharacterSelect = YOKAI;		//p
let e_OhmaTime = NEUTRAL;			//
let b_DualCharacter = false;			//`[ۂ
let b_LastSpellFlag = false;		//XgXy
let b_TimeCardAppear = b_TimeCard;	//tO
let n_TimeCardGet = 0;				//Ǘp


//L[`FbNp-----------
let ab_KeyStatus = [ false, false, false, false, false, false, false ];
let ae_KeyKind = [ VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_SHOT, VK_SLOWMOVE ];

let n_TIMER = 0;
let n_optRad = 0;

@Initialize{

	SetAutoEffect(false);

	LoadGraphic(img_Yokai);
	LoadGraphic(img_System);
	LoadGraphic(img_Char);
	LoadGraphic(img_BOL);
	LoadGraphic(img_Shot);
	LoadSE(se_Shot);
	LoadSE(se_Chip);
	LoadSE(se_Shift);

	LoadGraphic(img_YukariSpell);
	LoadGraphic(img_Border);

	LoadPlayerShotData(current~"txt\teamBorder_Shot.dnh");

	SetCommonDataEx("Player_Eiya","ManipulationType", YOKAI);
	SetPlayerLifeImage( img_Yokai, 0, 0, 48, 48 );
	SetSpeed(an_MoveSpeed[0], an_MoveSpeed[1]);
	SetRibirthFrame( n_RebirthFrameBase );
	SetInitialBombCount( 3 );
	SetItemCollectLine( n_CollectLine );
	SetGrazeCircle( n_GrazeCircle );

	//evC[
	//ŊeL̕Kvȃ^XNN܂
	main_InitializeYokai;
	main_DrawPlayer;
	main_NaturalBorder;
	main_SearchRoutine;

	//ʕ

	main_BorderOfLife();	//Eł
	main_YouritsuAdmin();	//d̊Ǘ^XNł
	main_DisplayParamater();//dAȂǂ̕\^XNł
	main_TimeCardAdmin();	//̊Ǘ^XNł

	main_Border();
}

@MainLoop{
	n_PX = GetPlayerX;
	n_PY = GetPlayerY;

	if( !OnBomb ){
		SetSpeed(an_MoveSpeed[0], an_MoveSpeed[1]);
		SetIntersectionCircle( n_PX, n_PY, 1 );
	}
	if( !OnMissed ){
		if( ab_KeyStatus[5] ){
			if( n_SlowEffectAlpha < 20 ){
				n_SlowEffectAlpha++;
			}
		}
		else if( n_SlowEffectAlpha > 0 ){
			n_SlowEffectAlpha--;
		}
	}
	else{
		n_SlowEffectAlpha = 0;
	}

	//{ƖGɐڐGGe܂
	if( OnBomb() || GetTimeOfPlayerInvincibility()>0 ){
		DeleteEnemyShotToItemInCircle(SHOT,n_PX,n_PY,5);
	}

	//L[`FbNTu[`̌Ăяo
	func_KeyCheck();


	n_TIMER++;
	yield;
}

@Missed{MainLoop}

@SpellCard{
	if(b_AutoBomb){
		UseSpellCard("Dummy", true );
	}
	else if(!b_executeHyper){
		PlaySE("sePlayerSpellCard.wav");
		if(b_LastSpellFlag){
			UseSpellCard("EiyaYonzyuKekkai", true );
			AddBomb(-1);
			main_ChangeEffect( YOKAI, false );
		}
		else{
			UseSpellCard("YonzyuKekkai", true );
		}
	}
	b_executeHyper = false;
	b_AutoBomb = false;
}

@DrawLoop{


	SetRenderState(ALPHA);
	SetColor( 255, 255, 255 );

	SetTexture(img_Border);
	if( n_SlowEffectAlpha > 0 ){
		SetAlpha( 128*n_SlowEffectAlpha/20 );
		SetGraphicScale( (45-n_SlowEffectAlpha)/12, (45-n_SlowEffectAlpha)/12 );
		SetGraphicRect( 65, 65, 127, 127 );
		SetGraphicAngle( 0, 0, n_TIMER*3 );
		DrawGraphic(n_PX, n_PY);
		SetGraphicAngle( 0, 0, -n_TIMER*3 );
		DrawGraphic(n_PX, n_PY);
	}
	
	let n_tc = GetCommonDataDefaultEx("Player_Eiya","TimeCardNum",0);
	SetAlpha(255);
	if(n_level > 0){
		SetRenderState(SUBTRACT);
		SetGraphicScale(2.0,2.0);
		SetGraphicRect(64,128,95,159);
		SetGraphicAngle(0, 0, n_TIMER*6);
		DrawGraphic(n_PX, n_PY);

		SetRenderState(ALPHA);
		SetGraphicRect(n_level*25-25,160,n_level*25,184);
		SetGraphicAngle(0, 0, 0);
		SetGraphicScale(2.8,2.8);
		DrawGraphic(n_PX, n_PY);
		
		SetGraphicScale(0.35,0.35);
		SetRenderState(ALPHA);
		let num = 16;
		let da = 360/num;
		SetColor( 255, 255, 255 );
		SetGraphicRect(32,128,63,159);
		let n_temp = truncate(n_HyperRest*num);
		SetGraphicAngle(0, 0, n_TIMER*12);
		ascent(i in 0..n_temp){
			DrawGraphic(n_PX+32*cos(-90+i*da),n_PY+32*sin(-90+i*da));
		}
		let cl = 192*(n_HyperRest*num - n_temp)+63;
		SetColor(cl,cl,cl);
		SetAlpha(cl);
		DrawGraphic(n_PX+32*cos(-90+n_temp*da),n_PY+32*sin(-90+n_temp*da));
		SetAlpha(255);
		SetColor(63,63,63);
		ascent(i in n_temp+1..num){
			DrawGraphic(n_PX+32*cos(-90+i*da),n_PY+32*sin(-90+i*da));
		}
	}
	else if(n_tc >= 1000){
		SetGraphicScale(0.6,0.6);
		n_tc = truncate(n_tc/1000);
		if(n_tc>10){n_tc=10;}
		SetGraphicRect(0,128,31,159);
		SetGraphicAngle(0, 0, n_TIMER*6);
		DrawGraphic(n_PX, n_PY+32);
		SetGraphicRect(n_tc*25-25,160,n_tc*25,184);
		SetGraphicAngle(0, 0, 0);
		SetGraphicScale(0.8,0.8);
		DrawGraphic(n_PX, n_PY+32);
	}

	SetColor( 255, 255, 255 );
	SetAlpha(255);
	SetTexture(img_Yokai);

	SetGraphicScale( 1.0, 1.0 );
	SetAlpha( 255 );
	SetGraphicRect( _RectData[0], _RectData[1], _RectData[0]+48, _RectData[1]+48 );
	SetGraphicAngle( 0, 0, 0 );
	DrawGraphic(n_PX, n_PY);

	SetTexture(img_Border);
	if( n_SlowEffectAlpha > 0 ){
		SetAlpha( 255*n_SlowEffectAlpha/20 );
		SetGraphicRect( 1, 1, 63, 63 );
		SetGraphicScale( n_SlowEffectAlpha/24, n_SlowEffectAlpha/24 );
		DrawGraphic( n_PX, n_PY );
	}
	if( n_SlowEffectAlpha != 0 ){
		SetGraphicScale( 1, 1 );
		SetAlpha( n_SlowEffectAlpha*12 );
		SetGraphicRect( 0, 0, 64, 64 );
		SetGraphicAngle( 0, 0, 0);
		DrawGraphic( n_PX, n_PY );
	}
	if( e_OhmaTime != NEUTRAL ){
		SetGraphicScale( 1, 1 );
		SetRenderState(ADD);
		SetColor( 96, 96, 96 );
		SetGraphicRect( 128, 0, 192, 64 );
		SetGraphicAngle( 0, 0, n_TIMER*4 );
		DrawGraphic( n_PX, n_PY );
	}

	if(e_CharacterSelect == YOKAI){
		SetTexture(img_Yokai);
		SetAlpha( 255 );
		SetGraphicRect( 0, 144, 12, 156 );
		SetGraphicAngle( 0, 0, n_TIMER*6 );
		SetGraphicScale( 1.2, 1.2 );
		if(n_level == 10){
			ascent(i in 0..6){DrawGraphic(n_PX+48*cos(n_TIMER*1+i*60), n_PY);}
		}
		else if(n_level > 6){
			ascent(i in 0..4){DrawGraphic(n_PX+48*cos(n_TIMER*3+i*90), n_PY);}
		}
		else if(n_level > 3){
			ascent(i in 0..2){DrawGraphic(n_PX+48*cos(n_TIMER*3+i*180), n_PY);}
		}
	}}

@Finalize{

	DeleteGraphic(img_Yokai);
	DeleteGraphic(img_System);
	DeleteGraphic(img_Char);
	DeleteGraphic(img_BOL);
	DeleteGraphic(img_Shot);
	DeleteSE(se_Shot);
	DeleteSE(se_Chip);
	DeleteSE(se_Shift);

	DeleteGraphic(img_YukariSpell);
	DeleteGraphic(img_Border);
}


#include_function".\txt\Yukari_Main.dnh"
#include_function".\txt\SharedTask.dnh"
#include_function".\txt\SlowEffect.dnh"
#include_function".\txt\BorderOfLife3.dnh"

}//end script

#include_script".\txt\Yukari_Spell.dnh"
#include_script".\txt\Dummy_Spell.dnh"
