#東方弾幕風
#Title[No.014　悲呪「憂いのマトリョーシカ　-Easy-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\弾幕集.txt"

	let name    = "悲呪「憂いのマトリョーシカ　-Easy-」";

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetCenterY;

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1750);
	SetTimer(49);
	SetScore(2000000 + spellbonus);
	SetDamageRate(50,10);
	SetInvincibility(120);

	LoadGraphic(imgboss2);
	SetTexture(imgboss2);
	SetGraphicRect(0,0,127,127);
	Shot(0);
	Move();
	}

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss2);
	MasicPointAddSpellCard;
	loop(18 + scorebonus){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}

	}

	task Move(){
	loop{
	yield;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}
	Wait(60);
	CreateEnemyFromScript("DOLL1",0,0,0,0,level);
	loop{
	yield;
	}
	}
}

script_enemy DOLL1
{
#include_function ".\弾幕集.txt"

	@Initialize{
	SetX(GetCenterX);
	SetY(GetCenterY);
	SetLife(1000);
	SetScore(10000);
	SetDamageRate(0,0);

	SetTexture(imgboss2);
	SetGraphicRect(766,0,798,32);
	Shot(0);
	Move();
	}

	@MainLoop{
	ChackBonus;

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	MasicPointAddNormal;
	}

	task Move(){
	loop{
	yield;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}

	task ShotA(level){
	let angle = 90;
	let wait = [17,13,11,7];
	loop{
	while(angle <= 180){CreateShot01(GetX,GetY,2,angle,BLUE21,0);
	CreateShot01(GetX,GetY,2,angle+180,BLUE21,0);
	if(level > 1){CreateShot01(GetX,GetY,2,angle+90,BLUE21,0);
	CreateShot01(GetX,GetY,2,angle-90,BLUE21,0);}
	loop(wait[level]){yield;angle++;}}
	while(angle >= 0){
	CreateShot01(GetX,GetY,2,angle,BLUE21,0);
	CreateShot01(GetX,GetY,2,angle+180,BLUE21,0);
	if(level > 1){CreateShot01(GetX,GetY,2,angle+90,BLUE21,0);
	CreateShot01(GetX,GetY,2,angle-90,BLUE21,0);}
	loop(wait[level]){yield;angle--;}}
	}
	}

	Wait(30);
	ShotA(0);
	Wait(90);
	CreateEnemyFromScript("DOLL2",0,0,0,90,level);
	CreateEnemyFromScript("DOLL2",0,0,0,-90,level);
	if(level == 2){
	CreateEnemyFromScript("DOLL2",0,0,0,0,level);
	CreateEnemyFromScript("DOLL2",0,0,0,180,level);
	}
	if(level == 3){
	CreateEnemyFromScript("DOLL2",0,0,0,30,level);
	CreateEnemyFromScript("DOLL2",0,0,0,150,level);
	CreateEnemyFromScript("DOLL2",0,0,0,-30,level);
	CreateEnemyFromScript("DOLL2",0,0,0,-150,level);
	}
	loop{
	let Angle = -90+rand(-10,10)-level * 20;
	loop(level * 4 + 1){
	GravityShot(GetX,GetX,1.5,Angle, 0.02, 90, PURPLE21, 20 );
	Angle += 10;
	}
	Wait(60 / (level+1));
	}
	}
}


script_enemy DOLL2
{
#include_function ".\弾幕集.txt"

	@Initialize{
	SetX(GetCenterX);
	SetY(GetCenterY);
	SetLife(1000);
	SetScore(10000);
	SetDamageRate(0,0);

	SetTexture(imgboss2);
	SetGraphicRect(766,0,798,32);
	Shot(0);
	Move();
	}

	@MainLoop{
	ChackBonus;

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	MasicPointAddNormal;
	}

	task Move(){
	let x = GetCenterX;
	let y = GetCenterY;
	let Angle = GetAngle;
	let radius = 128;
	SetMovePosition02(x+radius*cos(Angle),y+radius*sin(Angle),64);
	loop(64){yield;}
	loop{
	Angle++;
	SetMovePosition02(x+radius*cos(Angle),y+radius*sin(Angle),1);
	yield;
	}
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}

	task ShotA(level){
	loop(64){yield;}
	loop{
	let angleA = GetAngle;
	loop(8){
	CreateShot01(GetX,GetY,2,angleA+90,ORANGE21,10);
	CreateShot01(GetX,GetY,2,angleA-90,ORANGE21,10);
	CreateShot01(GetX,GetY,2,angleA,ORANGE21,10);
	CreateShot01(GetX,GetY,2,angleA+180,ORANGE21,10);
	angleA++;
	Wait(60 / (level+1));
	}
	loop(60){yield;	angleA++;}
	}
	}

	Wait(30);
	ShotA(0);
	loop{
	
	yield;
	}
	}
}