#東方弾幕風
#Title[「ドゥームズデイ-Easy」]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "「ドゥームズデイ-Easy」";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_eiki.png"; 
    let imgFam  = csd ~ "img\familiar.png";
    let imgBG  = csd ~ "..\img\st6bg1.png";
SetRateScoreSystemEnable(false);
    // 初期位置
    let xIni    = GetCenterX;
    let yIni    = GetClipMinY + 128;
	let wIni=60;
	let DrawY=330;
	let count=-wIni;

	#include_function ".\..\txt\SpellCardBonusDefine.txt"
	let SpellTimer=120;

	let bgy=0;
	let EnemyLife=2500;
    @Initialize {

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

        SetLife(2500);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgBG);
	InitializeAction();
	SetEffectForZeroLife(60,200,200);
        TMain;
    }

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


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

	DrawSpellHistory;
    }

task Alpha
{
	loop
	{
		if(GetTimeOfPlayerInvincibility>15)
		{
     	   		SetAlpha(0);
			while(GetTimeOfPlayerInvincibility>0){yield;}
			wait(60);
     			SetAlpha(255);
		}
		yield;
	}
}

    @Finalize {
        DeleteGraphic(imgBoss);
        DeleteGraphic(imgBG);
		EndSpellHistory(99);
    }
	@BackGround
	{
		SetTexture(imgBG);
		SetGraphicRect(0,0,1280,960+bgy);
		SetColor(150,150,150);
		SetAlpha(100);
		DrawGraphic(224, 240);
		bgy+=3;
	}
    // メインタスク
task TMain 
{
	standBy;
	spell;
	Trate;
	Shot1;
	Shot2;
	Laser;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(120);
     	SetDamageRate(20, 20);
	loop
	{
		if(GetTimeOfPlayerInvincibility>15)
		{
     	   		SetDamageRate(1, 1);
			while(GetTimeOfPlayerInvincibility>0){yield;}
			wait(60);
     			SetDamageRate(20, 20);
		}
		yield;
	}
}




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 Shot1
{
wait(180);
let color=165;
let angle=90;
let speed=2.0;
let rad=[];
rad=[20,40,60,80];
loop
{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
	}
	angle+=8;
	wait(35);
}
}

task Shot2
{
wait(180);
let color=170;
let angle=90;
let speed=2.0;
let rad=[];
rad=[20,40,60,80];
loop
{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180,color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[0],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[0],color,5);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[1],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[1],color,5);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[2],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[2],color,5);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle-rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180+rad[3],color,5);
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer+angle+180-rad[3],color,5);
	}
	angle-=8;
	wait(35);
}
}

task Laser
{
loop
{
		Effect;
		CreateLaserA(0,GetX,GetY,800,90,PURPLE01,60);		
		SetLaserDataA(0,0,GetAngleToPlayer,0,0,0,0);
		SetShotKillTime(0,120);
		FireShot(0);
		wait(240);
}
}

task Effect
{
let rad=[];
let color1=RED01;
let color2=BLUE01;
rad=[15,30,45,60];
	EffectLaser(GetAngleToPlayer+90,color1);
	EffectLaser(GetAngleToPlayer+90+rad[0],color1);
	EffectLaser(GetAngleToPlayer+90-rad[0],color1);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
		EffectLaser(GetAngleToPlayer+90+rad[1],color1);
		EffectLaser(GetAngleToPlayer+90-rad[1],color1);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
		EffectLaser(GetAngleToPlayer+90+rad[2],color1);
		EffectLaser(GetAngleToPlayer+90-rad[2],color1);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
		EffectLaser(GetAngleToPlayer+90+rad[3],color1);
		EffectLaser(GetAngleToPlayer+90-rad[3],color1);
	}

		EffectLaser(GetAngleToPlayer-90,color2);
		EffectLaser(GetAngleToPlayer-90+rad[0],color2);
		EffectLaser(GetAngleToPlayer-90-rad[0],color2);
	if(GetLife<EnemyLife*3/4 || GetTimer<90)
	{
		EffectLaser(GetAngleToPlayer-90+rad[1],color2);
		EffectLaser(GetAngleToPlayer-90-rad[1],color2);
	}
	if(GetLife<EnemyLife*2/4 || GetTimer<60)
	{
		EffectLaser(GetAngleToPlayer-90+rad[2],color2);
		EffectLaser(GetAngleToPlayer-90-rad[2],color2);
	}
	if(GetLife<EnemyLife*1/4 || GetTimer<30)
	{
		EffectLaser(GetAngleToPlayer-90+rad[3],color2);
		EffectLaser(GetAngleToPlayer-90-rad[3],color2);
	}
}

task EffectLaser(angle,color)
{

	CreateLaserA(0,GetX,GetY,800,20,color,60);		
	SetLaserDataA(0,0,angle,0,0,0,0);
	SetShotKillTime(0,120);
	FireShot(0);
}

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