script_enemy_main
{
	#include_function ".\Bullet_function.txt"
	#include_function ".\Enemy function.txt"

	@Initialize{
	SetCommonData("E36_X",GetX);
	SetCommonData("E36_Y",GetY);
	SetX(GetCenterX);
	SetY(0);
	SetLife(1);
	SetScore(40000);
	SetDamageRate(0,0);
	LoadGraphic(imgyoukou);
	LoadGraphic(imgzako);
	SetTexture(imgyoukou);
	SetGraphicRect(256,128,384,256);
	Shot(GetArgument);
	Move();
	}

	@MainLoop{
	ChackBonus;
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{

	}

	task Shot(level){

	task SeparateShot(angle,level){
	let a = 7;
	let b = 1;
	let c = 0;
	let d = 1;
	loop(240){
	CreateShotA(1,GetX,GetY,15);
	CreateShotA(2,GetX,GetY,15);
	SetShotDataA(1,0,2.5,angle+c,0,0,3,BLUE21);
	SetShotDataA(2,0,2.5,angle+c,0,0,3,AQUA21);
	SetShotDataA(1,50,NULL,angle+a+c,0,0,3,BLUE21);
	SetShotDataA(2,50,NULL,angle-a+c,0,0,3,AQUA21);
	FireShot(1);
	FireShot(2);
	loop(5){yield;}
	if(a <= 30&&b == 1){a += 3;}
	if(a > 30&&b == 1){b = 0;}
	if(a >= -30&&b == 0){a -= 3;}
	if(a < -30&&b == 0){b = 1;}
	if(level >= 2){
	if(c <= 30&&d == 1){c += 2.5;}
	if(c > 30&&d == 1){d = 0;}
	if(c >= -30&&d == 0){c -= 2.5;}
	if(c < -30&&d == 0){d = 1;}
	}
	}
	}

	let Loop = [10,15,15,20];
	let wait = [60,40,35,30];

	SeparateShot(30,level);
	SeparateShot(90,level);
	SeparateShot(150,level);
	SeparateShot(210,level);
	SeparateShot(270,level);
	SeparateShot(330,level);
	loop(Loop[level]){
	loop(wait[level]){yield;}
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer,PURPLE03,10);
	if(level >= 1){
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer-8,PURPLE03,10);
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer+8,PURPLE03,10);
	}
	if(level >= 2){
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer-4,PURPLE03,10);
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer+4,PURPLE03,10);
	}
	loop(wait[level]){yield;}
	Allshot(1,rand(0,360),level * 18 + 12,RED05,10);
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer,PURPLE03,10);
	if(level >= 1){
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer-4,PURPLE03,10);
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer+4,PURPLE03,10);
	}
	if(level >= 2){
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer-8,PURPLE03,10);
	CreateShot01(GetX,GetY,2.7,GetAngleToPlayer+8,PURPLE03,10);
	}
	}
	loop(90){yield;}
	}


	task Move(){
	yield;
	SetMovePosition02(GetCommonData("E36_X"),GetCommonData("E36_Y"),80);
	loop(1260){yield;}

	loop(10){
	loop(100 + scorebonus * 2){
	let angle = rand(0,360);
	let radius = rand(64,192);
	let x = GetX + cos(angle) * radius;
	let y = GetY + sin(angle) * radius;
	CreateItem(ITEM_SCORE,x,y);}

	yield;}

	FullItemSet(GetX,GetY);

	SetMovePosition02(GetCommonData("E36_X"),0,80);
	loop(80){yield;};
	VanishEnemy;
	}

}