#東方弾幕風
#Title[No.042　想起「ジャックナイフ　-Easy-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{

#include_function ".\弾幕集.txt"
	let name    = "想起「ジャックナイフ　-Easy-」";
	let frame   = 0;

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetClipMinY + 120;

	@Initialize{
	SetCommonData("ON_SPELL",1);
	CutIn(YOUMU,name,"",0,0,0,0);
	SetLife(2250);
	SetTimer(49);
	SetScore(400000 + spellbonus);
	SetDamageRate(50,7);

	LoadGraphic(imgboss42);
	SetTexture(imgboss42);
	SetGraphicRect(0,0,63,63);

	Shot(0);
	yield;
	SetMovePosition03(xini,yini,5,10);
	}

	@MainLoop{
	ChackBonus;
	SetCollisionA(GetX,GetY,32);
	SetCollisionB(GetX,GetY,24);

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss42);
	MasicPointAddSpellCard;
	loop(30 + scorebonus){
	let x = GetX + rand(-32,32);
	let y = GetY + rand(-32,32);
	CreateItem(ITEM_SCORE,x,y);
	}
	SetCommonData("ON_SPELL",0);
	}

	function StopKnife(radius,speed,bullet,count){
	let Angle = rand(0,360);
	CreateShotA(254,GetPlayerX + radius * sin(Angle),GetPlayerY + radius * cos(Angle),0);
	SetShotDataA(254,0,0,GetAngleToPlayer,0,0,0,bullet);
	SetShotDataA(254,150 - count,speed,NULL,0,0,3,bullet);
	FireShot(254);
	}

	function AttackKnife(knifes,angle,speed){
	let angleA = angle;
	loop(knifes){ReflectShot( GetX, GetY, 1, angleA , 1, true, true, true, true, BLUE32, 0 );
	angleA++;}
	}

	task Shot(level){
	loop{
		let count = 0;
		loop(90){yield;}
		loop(60 + level * 15){CreateShot01(GetX,GetY,3,rand(0,360),RED32,0);
			yield;
			yield;}
		loop(60){yield;}
		TimeStop(150,1,1,1);
		loop(90){count++;
			StopKnife(128 - level * 24,2,AQUA32,count);
			yield;}
		loop(210){yield;}
		loop(25 + level * 5){AttackKnife(rand(level + 2, 4 + level * 2),rand(0,360),2);
			loop(8){yield;}}
		}
	}
}