#東方弾幕風
#Title[環符「フェアリーサークル」]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "環符「フェアリーサークル」";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_daiyousei.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;

	let Bonus;
	let DBonusItem;
	alternative(GetCommonDataDefault("SELECTEDDIFFICULT","Normal"))
	case("Easy")
	{
		DBonusItem=1;
	}
	case("Normal")
	{
		DBonusItem=2;
	}
	case("Hard")
	{
		DBonusItem=3;
	}
	case("Lunatic")
	{
		DBonusItem=4;
	}
	let StandardSpellBonus=GetCommonDataDefault("BONUSPOINT",10000)*(20*DBonusItem+20*GetCommonDataDefault("STAGEPROGRESS",2));
	let SpellTimer=50;
	let SpellBonus=StandardSpellBonus/3;

    @Initialize {

	StartSpellHistory(1);
        SetLife(800);
        SetDamageRate(5, 5);
        LoadGraphic(imgBoss);
        LoadGraphic(imgFam);
        SetTexture(imgBoss);
	InitializeAction();
        TMain;
    }

    @MainLoop {
        SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;
    }

    @DrawLoop {
        DrawGraphic(GetX, GetY);
	DrawBoss( imgBoss );
	DrawSpellHistory;
    }

    @Finalize {
        DeleteGraphic(imgBoss);
	EndSpellHistory(1);
	loop(10)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }

    // メインタスク
task TMain 
{
	yield;
	standBy;
	spell;
	Trate;
	Shot;
}

task Trate
{
	wait(120);
        SetDamageRate(25, 25);
}




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

sub spell//発動モーション
{
        CutIn(YOUMU, name, "", 0, 0, 0, 0);
        SetTimer(SpellTimer);
        SetScore(SpellBonus);
	SetAction(ACT_SPELL,90);
	wait(90);
}


task Shot
{
let w=3;
let r=70;
loop
{
let angle=rand(0,360);
let angle2=angle-180;
	ascent(let bw in 0..30)
	{
		ascent(let i in 0..3)
		{
		CreateShotA(1,GetX+r*cos(angle)+r*cos(angle2),GetY+r*sin(angle)+r*sin(angle2),30);
		SetShotDataA(1,0,0,0,0,0,0,RED01);
		SetShotDataA(1,210-w*bw,1,GetAngleToPlayer+rand(-120,120),0,0,0,RED01);
		FireShot(1);
		angle+=120;
		angle2+=120;
		}
		wait(w);
		angle2+=10;
	}

angle+=60;
angle2=angle-180;

	ascent(let bw in 0..30)
	{
		ascent(let i in 0..3)
		{
		CreateShotA(1,GetX+r*cos(angle)+r*cos(angle2),GetY+r*sin(angle)+r*sin(angle2),30);
		SetShotDataA(1,0,0,0,0,0,0,BLUE01);
		SetShotDataA(1,120-w*bw,1,GetAngleToPlayer+rand(-120,120),0,0,0,BLUE01);
		FireShot(1);
		angle+=120;
		angle2+=120;
		}
		wait(w);
		angle2-=10;
	}
wait(120);
}
}



#include_function ".\..\txt\data.txt"
#include_function ".\..\txt\Spelldata.txt"
#include_function ".\..\lib/lib_anime_Daiyousei.txt"
}
