#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["YukariNon01"]
#Text["YukariNon01"]
#Background["./NoobSystem/Default_Background_IceMountain.txt"]
#BGM["./Overrate.mp3"]
#System["./NoobSystem/Default_System2.txt"]
#Player["./Reisen/Reisen.txt"]

#include"./Shot/AllStarShot_Const.dnh"
#include"./NoobSystem/Default_Effect.txt"
#include"./Function/Basic.txt"
#include"./Function/SoundFunctions.txt"
#include"./Function/EffectFunctions.txt"
#include"./Animations.txt"

let objEnemy;
let cx = GetStgFrameWidth/2;
let ct = GetStgFrameHeight/2;
@Initialize
{
	objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	ObjEnemy_SetDamageRate(objEnemy, 0, 0);
	TWork;
	TAnimate("Mima",GetCurrentScriptDirectory~"dot_yukari.png");
	TEnd;
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objEnemy,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),18);
	ObjEnemy_SetIntersectionCircleToShot(objEnemy,ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),24);
	yield;
}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(3000);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(60);
	}
}

//----------------------------------------------------

//----------------------------------------------------
task TWork
{
	ObjMove_SetPosition(objEnemy,GetStgFrameWidth/2,-GetStgFrameHeight/2);
	yield;
	ObjMove_SetDestAtWeight(objEnemy, GetStgFrameWidth/2, 120, 10,15);
	DamageRateAtFrame(100, 50,240);
	wait(90);
	YukariWave;
}

task YukariWave
{
	let count = 0;
	let way = 1;
	PlaySound("Charge2",100,0);
	SakuraCharge("PURPLE");
	wait(60);
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
	{
		ascent(n in 0..31)
		{
			PlaySound("Shot1",100,0);
			ascent(i in 0..10)
			{
				let angle = i*36+count*5*way;
				CreateShotA1(GetEnemyX,GetEnemyY,3,angle,KUNAI_GREEN,10);
			}
			if(count>10 && count%6==0)
			{
				PlaySound("BulletWave",100,0);
				ascent(i in 0..24)
				{
					let angle = i*15+count*4*way;
					CreateShotA2(GetEnemyX,GetEnemyY,1,angle,0.03,4,SMALL_MAGENTA,15);
				}			
			}
		count++;
		wait(5);
		}
		count = 0;
		wait(30);
		BorderMove(90,GetStgFrameWidth-90,90,150,10,90);
		wait(30);
		way *=-1;
	}
}



//BorderMove(90,GetStgFrameWidth-90,90,150,10,90);

//----------------------------------------------------
task TEnd
{
	while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
	{
		yield;
	}

	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);
	TExplosionA(ex, ey, 10, 0.6);
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	Obj_Delete(objEnemy);
	DeleteAllSound;
	loop(30)
	{
		DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
		yield;
	}

	CloseScript(GetOwnScriptID());
}
