script_enemy_main {
	let imgEBlue	= GetCurrentScriptDirectory() ~ "\img\faily_blue.png";
	let imgERed	= GetCurrentScriptDirectory() ~ "\img\faily_red.png";
	#include_function ".\lib\setting_nue.txt"
	
	let BASE_ZANKI	= GetPlayerLife();
	let BASE_BOMB	= GetPlayerBomb();
	
	@Initialize {
		SetLife(9999);
		SetDamageRate(0, 0);

		LoadGraphic(imgEBlue);
		LoadGraphic(imgERed);
		LoadGraphic(imgNue);

		TMain;
	}

	@MainLoop {
		SetCollisionB(GetX+OF_X, GetY+OF_Y, 16);
		yield;
	}

	@DrawLoop {
		//敵画像はエフェクトで描画
	}

	@Finalize {
	}

	// メインタスク
	task TMain {
		yield;
		start_nue;

		TShot;
		TMove;
	}

	//弾射出タスク
	task TShot()
	{
		wait(180);
		shot_nueyousei(2, -90, 20, "NueBlue");
		wait(360);
		shot_nueyousei(2, 90, -20, "NueRed");
		wait(360);
		shot_nueyousei(2.5, 120, 20, "NueBlue");
		wait(360);
		shot_nueyousei(3, 120, -20, "NueRed");
		wait(360);
	}
	
	task TMove()
	{
		SetMovePositionHermite(GetCenterX, GetClipMinY+150, 150, 0, 400, 60, 200);
		wait(1500);
		SetMovePositionHermite(GetX-20, GetY-20, 250, 0, 250, 0, 120);
		wait(120);

		//ぬえプレゼント
		if (BASE_ZANKI == GetPlayerLife() && BASE_BOMB == GetPlayerBomb())
			{ CreateItem(ITEM_1UP, GetX, GetY); }
		else
			{ CreateItem(ITEM_BOMB, GetX, GetY); }

		SetMovePositionHermite(GetClipMinX-60, GetClipMinY, 250, 0, 300, 0, 100);
		wait(100);
		
		VanishEnemy();
	}
	
	//妖精射出
	task shot_nueyousei(speed, angle, way, type)
	{
		let i = 0;
		let ip = 90;
		if (way < 0) { ip = -90; }
		loop(absolute(way))
		{
			let a = angle+i*360/way;
			CreateEnemyFromScript(type, GetX+cos(a)*64+OF_X, GetY+sin(a)*64+OF_Y, 2, a+ip, speed);
			i++;
			loop (3) { yield; }
		}
	}
}

// 妖精さん
script_enemy NueBlue {
	let imgEmeny	= GetCurrentScriptDirectory() ~ "\img\faily_blue.png";
	#include_function ".\lib\setting_emeny.txt"

	let shot_speed = GetArgument();
	let ANGLE = GetAngle();

	@Initialize {
		Initialize_Fairy(SMALL_CAP);	//使用する妖精を設定
		SetLife(30);
		SetScore(1000);
		SetDamageRate(100, 100);

		TMain;
	}

	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 13);

		yield;
	}

	@DrawLoop {
		DrawFairy(imgEmeny);	//妖精を描画
	}

	@Finalize()
	{
		if (!BeVanished())
		{
			loop(4)
			{
				let r = rand(0, 10^2)^0.5;
				let a = rand(0, 360);
				CreateItem(ITEM_SCORE, GetX+r*cos(a), GetY+r*sin(a));
			}
		}
	}

	task TMain {
		yield;
		TMove;
		TShot;
	}

	task TMove {
		loop
		{
			ANGLE += 0.33;
			SetAngle(ANGLE);
			yield;
		}
	}

	task TShot {
		yield;
		
		loop(3)
		{
			loop(10)
			{
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle+90, -0.033, shot_speed, BLUE11, 10);
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle+135, -0.033, shot_speed, BLUE11, 10);
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle+180, -0.033, shot_speed, BLUE11, 10);
				StopSE(SE_SHOT);
				PlaySE(SE_SHOT);
				loop(3){ yield; }
			}
			loop(39) { yield; }
		}
		loop(90) { yield; }
		VanishEnemy;
	}
}

// 妖精さん
script_enemy NueRed {
	let imgEmeny	= GetCurrentScriptDirectory() ~ "\img\faily_red.png";
	#include_function ".\lib\setting_emeny.txt"
	
	let shot_speed = GetArgument();
	let ANGLE = GetAngle();

	@Initialize {
		Initialize_Fairy(SMALL_CAP);	//使用する妖精を設定
		SetLife(30);
		SetScore(1000);
		SetDamageRate(100, 100);

		TMain;
	}

	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 13);

		yield;
	}

	@DrawLoop {
		DrawFairy(imgEmeny);	//妖精を描画
	}

	@Finalize()
	{
		if (!BeVanished())
		{
			loop(4)
			{
				let r = rand(0, 10^2)^0.5;
				let a = rand(0, 360);
				CreateItem(ITEM_SCORE, GetX+r*cos(a), GetY+r*sin(a));
			}
		}
	}

	task TMain {
		yield;
		TMove;
		TShot;
	}

	task TMove {
		loop
		{
			ANGLE -= 0.33;
			SetAngle(ANGLE);
			yield;
		}
	}

	task TShot {
		yield;
		
		loop(2)
		{
			loop(10)
			{
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle+180, -0.033, shot_speed, RED11, 10);
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle+235, -0.033, shot_speed, RED11, 10);
				CreateShot02(GetX, GetY, shot_speed+1, GetAngle-90, -0.033, shot_speed, RED11, 10);
				PlaySE(SE_SHOT);
				loop(3){ yield; }
			}
			loop(39) { yield; }
		}
		loop(90) { yield; }
		VanishEnemy;
	}
}
