script_enemy_main
{
        let csd     = GetCurrentScriptDirectory;
	let speed = GetSpeed;
	let angle = GetAngle;
	let num = GetArgument;
	let imgEnemy;
	if(num==1)
	{
		imgEnemy=csd~"..\lib\fairy_red.png";
	}
	if(num==2)
	{
		imgEnemy=csd~"..\lib\fairy_blue.png";
	}
	let SelectedDifficult=GetCommonDataDefault("SELECTEDDIFFICULT","Normal");

    @Initialize {
        SetLife(50);
        SetDamageRate(100,100);
	SetTexture(imgEnemy);
	Initialize_Fairy(0);
	Tmain;
	}

    @MainLoop {
	SetCollisionA(GetX(),GetY(),32);
        SetCollisionB(GetX(),GetY(),16);
	yield;
    }

        @DrawLoop {
		DrawFairy(imgEnemy );
	}

        @Finalize
        {
		if(!BeVanished)
		{
			loop(3)
			{
				ItemSet(GetX+rand(-30,30),GetY+rand(-30,30),num);
			}
		}
        } 

task Tmain
{
yield;
GetDamege;
move;
shot;
eraze;
}

task GetDamege
{
loop
{
	if(GetHitCount!=0)
	{
		SetColor(150,150,255);
		wait(10);
	}
	else
	{
		SetColor(255,255,255);
	}
yield;
}
}

task move
{
	SetSpeed(speed);
	SetAngle(angle);
}

task shot
{
alternative(SelectedDifficult)
case("Easy")
{
	wait(30);
	loop(5)
	{
		CreateShot01(GetX,GetY,1.5,90,YELLOW01,5);
		CreateShot01(GetX,GetY,1.5,110,YELLOW01,5);
		CreateShot01(GetX,GetY,1.5,70,YELLOW01,5);
		wait(30);
	}
}
case("Normal")
{
	wait(30);
	loop(5)
	{
		CreateShot01(GetX,GetY,2.5,90,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,105,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,75,YELLOW01,5);
		wait(30);
	}
}
case("Hard")
{
	wait(30);
	loop(5)
	{
		CreateShot01(GetX,GetY,2.5,90,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,105,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,75,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,120,YELLOW01,5);
		CreateShot01(GetX,GetY,2.5,60,YELLOW01,5);
		wait(30);
	}
}
case("Lunatic")
{
	wait(30);
	loop(5)
	{
		CreateShot01(GetX,GetY,3,90,YELLOW01,5);
		CreateShot01(GetX,GetY,3,105,YELLOW01,5);
		CreateShot01(GetX,GetY,3,75,YELLOW01,5);
		CreateShot01(GetX,GetY,3,120,YELLOW01,5);
		CreateShot01(GetX,GetY,3,60,YELLOW01,5);
		CreateShot01(GetX,GetY,3,135,YELLOW01,5);
		CreateShot01(GetX,GetY,3,45,YELLOW01,5);
		wait(30);
	}
}
}

task eraze
{
while(!BeVanished)
{
        	if(GetX<GetClipMinX-64||GetX>GetClipMaxX+64||GetY<GetClipMinY-32||GetY>GetClipMaxY+32)
        	{
        		VanishEnemy();
        	}
yield;
}
}

#include_function ".\..\txt/StageEnemydata.txt"
#include_function ".\..\lib\lib_anime_fairy.txt"
}
