#東方弾幕風
#Title[No.132 光符「セイレーンライトバニッシュ　-Hard-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "光符「セイレーンライトバニッシュ　-Hard-」";
	let count   = 0;

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

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

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

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

	//EX風ボムバリア
	if(OnBomb() == true){SetInvincibility(2);}
	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(level){
	loop{
	loop(level * -10 + 450){yield;}
	if(GetX >= GetPlayerX){
	SetMovePositionRandom01(rand_int(-8,0)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY - 180,GetClipMaxX - 128,GetCenterY - 120);
	}
	if(GetX < GetPlayerX){
	SetMovePositionRandom01(rand_int(0,8)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY - 180,GetClipMaxX - 128,GetCenterY - 120);
	}
	loop(110){yield;}
	}
	}

	task LightShot(x,y,angle,n,level){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetX(obj, x);
	Obj_SetY(obj, y);
	Obj_SetSpeed(obj, 2.2 - level * 0.4);
	Obj_SetAngle(obj, angle + rand(-n,n));
	ObjShot_SetGraphic(obj, 48);
	ObjShot_SetDelay(obj, 20);
	
	while( !Obj_BeDeleted(obj) ){
	if(GetCommonData("CHENGEANGLE") == 1){Obj_SetAngle(obj, GetCommonData("LIGHTSHOT_ANGLE") + rand(-n,n));}
	yield;
	}
	}

	task LightShotCommand(level){
	SetCommonData("CHENGEANGLE",0);

	loop{
	SetCommonData("LIGHTSHOT_ANGLE",90);
	SetCommonData("CHENGEANGLE",1);
	yield;
	SetCommonData("CHENGEANGLE",0);

	loop(45 + level * 7){
	loop(15 - level * 4){yield;}
	LightShot(rand(GetClipMinX,GetClipMaxX),0,GetCommonData("LIGHTSHOT_ANGLE"),level * 2 + 5,level);
	}

	SetCommonData("LIGHTSHOT_ANGLE",180);
	SetCommonData("CHENGEANGLE",1);
	yield;
	SetCommonData("CHENGEANGLE",0);

	loop(45 + level * 7){
	loop(15 - level * 4){yield;}
	LightShot(GetClipMaxX,rand(GetClipMinY,GetClipMaxY),GetCommonData("LIGHTSHOT_ANGLE"),level * 2 + 5,level);
	}

	SetCommonData("LIGHTSHOT_ANGLE",270);
	SetCommonData("CHENGEANGLE",1);
	yield;
	SetCommonData("CHENGEANGLE",0);

	loop(45 + level * 7){
	loop(15 - level * 4){yield;}
	LightShot(rand(GetClipMinX,GetClipMaxX),GetClipMaxY,GetCommonData("LIGHTSHOT_ANGLE"),level * 2 + 5,level);
	}

	SetCommonData("LIGHTSHOT_ANGLE",0);
	SetCommonData("CHENGEANGLE",1);
	yield;
	SetCommonData("CHENGEANGLE",0);

	loop(45 + level * 7){
	loop(15 - level * 4){yield;}
	LightShot(0,rand(GetClipMinY,GetClipMaxY),GetCommonData("LIGHTSHOT_ANGLE"),level * 2 + 5,level);
	}

	}
	}

	task CreateLightLaser(level){
	//レーザータスク初期化
	let obj = Obj_Create(OBJ_LASER);
	Obj_SetX(obj, GetX);
	Obj_SetY(obj, GetY);
	Obj_SetAngle(obj, GetAngleToPlayer);
	ObjShot_SetGraphic(obj, WHITE11);
	ObjShot_SetDelay(obj, 60);//遅延時間：60フレーム
	ObjLaser_SetLength(obj,1000);
	ObjLaser_SetWidth(obj, 180 + level * 80);//レーザーの幅：180 + level * 80
	loop(300){yield;}
	Obj_Delete(obj);
	}

	task Shot(level){
	LightShotCommand(level);
	loop{
	Concentration01(level * -10 + 150);
	loop(level * -10 + 150){yield;}
	CreateLightLaser(level);
	loop(410){yield;}
	}
	}
}