#e[Player]	//@XNvgł邱Ƃ܂
#ScriptVersion[2]	//XNvgo[W2K{ł
#Menu[i`Ch]		//@Iʂŕ\郁j[ł
#Text[Ver.1.00
CFNCbNVbg
Tu@FNCbNu[
{@FuiE`Nv
UЗ́F
Ú͈F
xF
ᑬxF
]	//@Iʂŕ\eLXgł
#Image[.\img\image_luna.png]
#ReplayName[Luna]	//vCIɕ\镶łB8ȓłB

script_player_main
{
	let current = GetCurrentScriptDirectory();//JgfBNg擾
	let imgLuna = current~"img\Luna.png";
	let CutLuna = current~"img\cutin_Luna.png";
	let shotCount = -1;//eAŔ˂邽߂̕ϐ
	let bNextShot = false;//񉟂łeA˂邽߂̕ϐ(Â炢)
	let SubShot = false;

	@Initialize
	{	
		//@̏Ɉ񂾂Ăяo镔ł
		SetPlayerLifeImage(imgLuna,4,0,34,37);//c@̉摜
		LoadGraphic(imgLuna);
		SetSpeed(4,1.5);//ړxݒ
		SetRibirthFrame(7);
		SetInitialBombCount(3);
		LoadPlayerShotData(current~"LunaShotData.txt");
		SetItemCollectLine(125);//ACeCݒ
	}
	
	@MainLoop
	{
	if(!OnBomb){
		if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD || bNextShot==true) && shotCount==-1)
		{
			shotCount = 0;
			bNextShot = false;
		}
		if(GetKeyState(VK_SHOT)==KEY_HOLD && shotCount>0)
		{
			bNextShot = true;
		}

	if(!OnMissed&&!OnEvent){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{	//ᑬړ̎e
			if(shotCount%5 == 0)
			{
				PlaySE("sePlayerShot01.wav");
				MainShot(0,13,4);
				MainShot(5,12,3);
				MainShot(-5,12,3);
			}
			if(shotCount%10 == 0)
			{
				QuickShot(1);
			}
		}
		else
		{	//ړ̎e
			if(shotCount%5 == 0)
			{
				PlaySE("sePlayerShot01.wav");
				MainShot(0,13,4);
				MainShot(-15,12,3);
				MainShot(15,12,3);
				QuickShot(2);
			}
		}
	}

		if(shotCount >= 0)
		{
			shotCount++;
		}
		if(shotCount == 30)
		{
			shotCount=-1;
		}
		} else {shotCount=-1;}
		SetIntersectionCircle(GetPlayerX,GetPlayerY,1.5);//蔻o^	
		yield;
	}

task MainShot(SX,SP,SS){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX+SX,GetPlayerY-10);
	Obj_SetSpeed(obj,SP);
	Obj_SetAngle(obj,270);
	ObjShot_SetDamage(obj,SS);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,1);
	Obj_SetAlpha(obj,155);
}

task QuickShot(D){
	let speed = 0;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
	Obj_SetAngle(obj,rand(45,135));
	ObjShot_SetDamage(obj,D);
	ObjShot_SetPenetration(obj,50);
	ObjShot_SetGraphic(obj,2);
	Obj_SetAlpha(obj,155);
	loop(20){
		Obj_SetSpeed(obj,2-speed);
		speed=speed-0.1;
		yield;}
	loop(50){
		Obj_SetAngle(obj,270);
		Obj_SetSpeed(obj,speed);
		speed=speed+0.5;
		yield;}
}

	@Missed{
		}

	@SpellCard
	{	
		UseSpellCard("Tsukifu",true);
		CutIn(KOUMA,"uiE`Nv",CutLuna);
	}
	
	@DrawLoop
	{
		SetAlpha(255);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,0);
		SetTexture(imgLuna);
		if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			SetGraphicRect(40,0,79,38);
		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			SetGraphicRect(80,0,119,38);
		}
		else 
		{
			SetGraphicRect(0,0,39,38);
		}
		DrawGraphic(GetPlayerX(), GetPlayerY());	
	}
	
	@Finalize
	{
		DeleteGraphic(imgLuna);
	}
}

}

script_spell Tsukifu
{
	let current = GetCurrentScriptDirectory();
	let bom = current~"se\BOM2.wav";
	let i = 0;
	@Initialize
	{
		SetPlayerInvincibility(250);//GԂݒ
		shoot;
	}
	@MainLoop
	{
		CollectItems;
		yield;
	}
	@Finalize
	{
	}


task shoot{
	loop(50){yield;}
     	SetSpeed(2,1);
	PlaySE(bom);
        	let i = 0;
        	while( i < 30 )
        	{
        	ShotA(i*12,12);
        	ShotA(i*12,-12);
        	i++;
		}
	loop(200){yield;}
     	SetSpeed(6,3);
	PlaySE("seSuperNaturalBorder2.wav");
	End;
}

    	task ShotA(angle,speed){
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetPlayerX+cos(angle)*40,GetPlayerY+sin(angle)*40);
		Obj_SetSpeed(obj,6);
		ObjShot_SetDamage(obj,0.4);
		ObjShot_SetPenetration(obj,200);
		ObjShot_SetGraphic(obj,3);
		ObjShot_SetDelay(obj,0);
	loop{
		Obj_SetPosition(obj,GetPlayerX+cos(angle)*40,GetPlayerY+sin(angle)*40);
		Obj_SetAngle(obj,angle);
		angle=angle+6;
		yield;}
	}
}