#東方弾幕風
#Title[No.029　華符「セラギネラ９改　-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{
	SetCommonData("ON_SPELL",1);
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1750);
	SetTimer(39);
	SetScore(4500000 + spellbonus);
	SetDamageRate(50,10);
	SetInvincibility(180);

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

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss31);
	MasicPointAddSpellCard;
	CreateItem(ITEM_1UP,GetX,GetY);
	SetCommonData("ON_SPELL",0);
	}

	task Move(){
	loop{
	yield;
	}
	}

	task HoukakenranShot(level){
	let angleA1 = 0;
	let angleA2 = 0;
	let angleB1 = 180;
	let angleB2 = 180;

	function BackToShot01(x,y,speed,anglefirst,bullet,delay){
	CreateShotA(0,x,y,delay);
	SetShotDataA(0,0,speed,anglefirst,0,0,0,bullet);
	SetShotDataA(0,15,0,NULL,0,0,0,bullet);
	SetShotDataA(0,30,speed,anglefirst+180,0,0,0,bullet);
	FireShot(0);
	}
	
	loop{
	if(level <= 1){
	CreateShot01(GetX,GetY,1+level/3,angleA1,YELLOW21,15);
	CreateShot01(GetX,GetY,1+level/3,angleA2,YELLOW21,15);
	CreateShot01(GetX,GetY,1+level/3,angleB1,YELLOW21,15);
	CreateShot01(GetX,GetY,1+level/3,angleB2,YELLOW21,15);
	}
	if(level >= 2){
	BackToShot01(GetX,GetY,1+level/3,angleA1,YELLOW21,15);
	BackToShot01(GetX,GetY,1+level/3,angleA2,YELLOW21,15);
	BackToShot01(GetX,GetY,1+level/3,angleB1,YELLOW21,15);
	BackToShot01(GetX,GetY,1+level/3,angleB2,YELLOW21,15);
	}
	angleA1 += 7;
	angleA2 -= 7;
	angleB1 += 7;
	angleB2 -= 7;
	loop(6-level){yield;}
	}
	}

	task LineToPlayerShotA(x,y,minspeed,maxspeed,angle,shots,bullet){
	let angle = GetAngleToPlayer + angle;
	let speedA = minspeed + (maxspeed - minspeed) / shots;
	let speed = minspeed;
	loop(shots){
	CreateShot02(x,y,speed,angle,0.3,speedA,bullet,15);
	speedA += (maxspeed - minspeed) / shots;
	yield;
	}
	}

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

	Wait(45);
	HoukakenranShot(level);
	loop{
	Wait(30);
	Allshot(1+level/3,90,30 + 15 * level,RED21,15);
	Wait(30);
	if(level != 1){LineToPlayerShotA(GetX,GetY,1,2,15,10,BLUE31);
	LineToPlayerShotA(GetX,GetY,1,2,-15,10,BLUE31);}
	if(level >= 1){LineToPlayerShotA(GetX,GetY,1,2,0,10,BLUE31);}
	}
	}
}
