#東方弾幕風
#Title[幽香通常3-Easy]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "幽香通常3-Easy";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_yuka.png"; 
    let imgFam  = csd ~ "..\img\familiar.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;

    @Initialize {

       LoadUserShotData(GetCurrentScriptDirectory~".\..\img\shot_All.txt");

        SetLife(800);
        SetTimer(40);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);

	InitializeAction();
        TMain;
    }

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

    @DrawLoop {
	DrawBossShadow( imgBoss,150,0,255,255);
	DrawBoss( imgBoss );
    }

    @Finalize {
		DeleteGraphic(imgBoss);
    }

    // メインタスク
task TMain 
{
	standBy;
	wait(180);
	Trate;
	Shot;
	summon;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(120);
        SetDamageRate(25, 25);
}

task summon
{
let rangle=rand(0,360);
let dir=rand_int(0,1)*2-1;
loop
{
	CreateEnemyFromScript("Familiar", GetX,GetY,2,dir, 1);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,dir, -1);
	wait(600);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,-dir, 1);
	CreateEnemyFromScript("Familiar", GetX,GetY,2,-dir, -1);
	wait(600);
}
}


sub standBy//初期位置へ
{
	SetAction(ACT_MOVE, wIni);
	SetMovePosition02(xIni, yIni, wIni);
	SetInvincibility(wIni);
	wait(wIni);
}



task Shot
{
	loop
	{
	ascent(let i in 0..18)
	{
		CreateShot01(GetX,GetY,2,GetAngleToPlayer+i*20,26,5);
	}
		wait(45);
	}
}


#include_function ".\..\txt\data.txt"
#include_function ".\..\lib/lib_anime_Yuka.txt"
}

script_enemy Familiar {
    let csd     = GetCurrentScriptDirectory;
    let imgFam  = csd ~ "..\img\familiar.png";
	let num = GetArgument;
	let angle=GetAngle;
	let numdir=GetAngle;
	let speed=GetSpeed;
	let numY=0;
	let IniX=GetX;
	let IniY=GetY;
	if(absolute(num)==1)
	{
		numY=75;
	}
    @Initialize {
        SetLife(2000);
        SetScore(10000);
        SetDamageRate(50, 50);
        SetTexture(imgFam);
        setGraphic;
	SetSpeed(speed);
	SetAngle(angle);
	TMain;
    }

    @MainLoop {
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
    }

    task TMain {
        yield;
	shot;
	move;
    }

task move
{
	SetMovePosition02(GetEnemyX+120*num, GetEnemyY+60, 60);
}


task shot
{
wait(60);
let dir=numdir;
let angle=-15*num;
loop(20)
{
	ascent(let i in 0..6)
	{
		CreateShot01(GetX,GetY,3.0,angle+i*60,27,10);
	}
wait(3);
}

loop(20)
{
	ascent(let i in 0..6)
	{
		CreateShot01(GetX,GetY,3.0,angle+i*60,27,10);
	}
angle+=1.2*dir;
wait(3);
}
loop(40)
{
	ascent(let i in 0..6)
	{
		CreateShot01(GetX,GetY,3.0,angle+i*60,27,10);
	}
angle-=1.2*dir;
wait(3);
}
loop(40)
{
	ascent(let i in 0..6)
	{
		CreateShot01(GetX,GetY,3.0,angle+i*60,27,10);
	}
angle+=1.2*dir;
wait(3);
}
VanishEnemy;
}


    // グラフィックの設定
sub setGraphic{ SetGraphicRect( 0, 48, 48, 96); }
function wait(w)
{
loop(w){yield;}
}
}
