#搶曽抏枊晽
#Title[壴晞乽嶗壴偺恮-Easy乿]
#Text[]
#Image[.]
#BackGround[User]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main {
    let name    = "壴晞乽嶗壴偺恮-Easy乿";
let csd = GetCurrentScriptDirectory;
    let imgBoss =csd ~ "..\lib/dot_yuka.png"; 
    let imgFam  = csd ~ "img\familiar.png";
    let imgBG  = csd ~ "..\img\st4bg1.png";
    let imgBG2  = csd ~ "..\img\st4bg2.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=50;

	let bgy=0;
	let BGangle=0;
    @Initialize {

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

        SetLife(1000);
        SetDamageRate(1, 1);
        LoadGraphic(imgBoss);
        LoadGraphic(imgBG);
        LoadGraphic(imgBG2);
	InitializeAction();
        TMain;
    }

    @MainLoop {
	GetBossShadowPosition;
        SetCollisionA(GetX, GetY, 48);
        SetCollisionB(GetX, GetY, 8);
	Bonus=GetSpellCardBonusScore-(SpellBonus*3)/(SpellTimer*60);
        yield;
		bgy+=2;
		BGangle+=0.2;
    }

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

    @Finalize {
		DeleteGraphic(imgBoss);
		EndSpellHistory(47);
	loop(25)
	{
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),1);
		ItemSet(GetX+rand(-40,40),GetY+rand(-40,40),2);
	}
    }
	@BackGround
	{
		SetTexture(imgBG);
		SetGraphicRect(0,0,1280,1920+bgy);
		SetGraphicAngle(0,0,0);
		SetColor(150,150,150);
		SetAlpha(100);
		DrawGraphic(224, 240);	
		SetTexture(imgBG2);
		SetGraphicRect(0,0,640,640);
		SetGraphicAngle(0,0,BGangle);
		SetColor(150,150,150);
		SetAlpha(50);
		DrawGraphic(224, 240);	

	}
    // 儊僀儞僞僗僋
task TMain 
{
	standBy;
	spell;
	Trate;
	Shot;
}

task Trate
{
	while(OnBomb==true){yield;}
	wait(180);
        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 dir=rand_int(0,1)*2-1;
let w=300;
	loop
	{
	let pangle=0;
		ascent(let i in 0..6)
		{
			flower(i*60,pangle,dir);
		}
		wait(w);
	dir=dir*-1;
	}
}



task flower(angle,pangle,sdir)
{
let dir=1;
	ascent(let i in 0..20)
	{
		ascent(let j in 0..5)
		{
		/*	CreateShotA(0,GetX+i*20*cos(angle),GetY+i*20*sin(angle),10);
			//SetShotColor(200,200,200);
			SetShotDataA(0,0,1.6,angle+j*72+pangle,0,-0.2,0,191);
			SetShotColor(255,255,255);
			SetShotDataA(0,120,0,NULL,0,0.01,0.8+0.1*(i%5),47);
			FireShot(0);
		*/	ShotOuka(GetX+i*20*cos(angle),GetY+i*20*sin(angle),1.6,-0.2,0.01,0.8+0.1*(i%5),angle+j*72+pangle,10,191,47);
		}
		wait(3);
		dir=dir*-1;
pangle+=10*sdir;
	}
}

task ShotOuka(let x,let y,let Pspeed,let dispeed,let aspeed,let stopspeed,let angle,let delay,let graphic,let graphic2)
{
	let itemx=x;
	let itemy=y;
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y,);
	Obj_SetSpeed(obj, Pspeed);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, graphic);
	ObjShot_SetDelay(obj, delay);

	loop(delay)
	{
		itemx=Obj_GetX(obj);
		itemy=Obj_GetY(obj);
		if(Obj_BeDeleted(obj))
		{
			CreateShotChengeToItem(itemx,itemy);
			return;
		}
		yield;
	}
	loop(120)
	{
		if(Pspeed>=0)
		{
		Pspeed+=dispeed;
		}
		Obj_SetSpeed(obj, Pspeed);
		itemx=Obj_GetX(obj);
		itemy=Obj_GetY(obj);
		if(Obj_BeDeleted(obj))
		{
			CreateShotChengeToItem(itemx,itemy);
			return;
		}
		yield;
	}
	ObjShot_SetGraphic(obj, graphic2);
	while(!Obj_BeDeleted(obj))
	{
		if(Pspeed<=stopspeed)
		{
		Pspeed+=aspeed;
		}
		Obj_SetSpeed(obj, Pspeed);
		itemx=Obj_GetX(obj);
		itemy=Obj_GetY(obj);
		yield;
	}
	CreateShotChengeToItem(itemx,itemy);
}

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