#東方弾幕風
#Title[No.123 「梅雨の妖精弾壁　-Lunatic-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "「梅雨の妖精弾壁　-Lunatic-」";

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

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1000);
	SetTimer(100);
	SetScore(10000000 + spellbonus);
	SetDamageRate(20,100);

	LoadGraphic(imgboss71);
	SetTexture(imgboss71);
	SetGraphicRect(0,0,127,127);
	SetInvincibility(90);
	Shot(3);
	Move();
	LoadUserShotData(GetCurrentScriptDirectory~"11-221Shot_データ.txt");
	}

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}


	@Finalize{
	DeleteGraphic(imgboss73);
	MasicPointAddSpellCard;
	loop(200 + scorebonus * 10){
	let x = rand(GetX-96,GetX+96);
	let y = rand(GetY-96,GetY+96);
	CreateItem(ITEM_SCORE,x,y);}
	SetCommonData("ON_SPELL",0);
	}

	task Move(){
	loop{
	loop(180){yield;}
	SetMovePositionRandom01(rand_int(-4,4)*16,rand(-16,16),1,GetClipMinX + 64,GetClipMinY,GetClipMaxX - 64,128);
	}
	}

	function FairyWall(x,y,speed,level){
	CreateShotA(1,x,y,30);
	SetShotDataA(1,0,2,90,0,-0.1,0,BLUE32);
	SetShotDataA(1,50,NULL,NULL,0,0.08,speed,BLUE32);
	SetShotDataA(1,80,NULL,NULL,0,0.18,speed,BLUE32);
	SetShotDataA(1,110,NULL,NULL,0,0.64,speed,BLUE32);
	SetShotDataA(1,140,NULL,NULL,0,-speed/10,0,BLUE32);
	SetShotDataA(1,200,2,NULL,0,0,2,BLUE32);
	FireShot(1);
	}

	task FairyWallA(level){
	let mx =GetClipMinX();
	let Mx =GetClipMaxX();
	let x1;
	let x2;
	let y = GetCenterY - 120;
	let t1 = level * 2 + 1;
	let t2 = level * 2 + 1;

	function Naibun(a,b,c,d){
	let e = ((b - a) * c) / d;

	return e;
	}


	loop{
	let speed = 3;
	x1 = Naibun(mx,Mx,t1 - 1,t2);
	x2 = x1;

	while(x1 <= Mx){
	FairyWall(x1,y,speed,level);
	speed -= 0.15;
	x1 += 36 - level * 8;
	}
	while(x2 >= mx){
	FairyWall(x2,y,speed,level);
	speed -= 0.15;
	x2 -= 36 - level * 8;
	}
	t1--;
	loop(150){yield;}
	if(t1 <= 2){t1 = level * 2 + 1;}
	}
	}

	task Shot(level){
	loop(90){yield;}
	FairyWallA(level);
	RainShot(2.7,level * 0.4 + 2,85,BLUE23,20);
	loop{
	yield;
	}
	}
}