
#ScriptVersion[3]
#Title["TestPlayer"]
#Text["TestPlayer"]
#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_cirno.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*1.2,GetStgFrameHeight/2);
	wait(60);
	ObjMove_SetDestAtWeight(objEnemy, GetStgFrameWidth/2, 120, 10,15);
	DamageRateAtFrame(100, 50,240);
	wait(90);
	//CirnoWave;
}

task CirnoWave
{
	let way = 1;
	PlaySound("Charge2",100,0);
	SakuraCharge("BLUE");
	wait(60);
		ascent(n in 0..8-way*4)
		{
			let r = 10;
			PlaySound("Shot1",100,0);
			ascent(i in 0..24+way*12)
			{
				let angle = i*360/(24+way*12)+GetAngleToPlayer(objEnemy);
				ascent(j in 0..2)
				{
					CreateShotA1(GetEnemyX+r*cos(angle),GetEnemyY+r*sin(angle),1.5+j*1.5,angle,39.5-way*0.5,15);
				}
			}
			wait(20+way*10);
		}
		wait(25);
		BorderMove(90,GetStgFrameWidth-90,90,150,10,90);
		wait(25);
		let dir = GetAngleToPlayer(objEnemy);
		ascent(n in -3..4)
		{
			PlaySound("Shot2",100,0);
			ShotGun(dir+n*40*way);
			wait(15);
		}
		wait(20);
		//BorderMove(90,GetStgFrameWidth-90,90,150,10,90);
		wait(20);
		way *= -1;;
	
	task ShotGun(dir)
	{
		ascent(i in 3..8)
		{
			ascent(j in 0..i)
			{
				let sig = -i/2;
				CreateShotA1(GetEnemyX,GetEnemyY,5.5-i/2,j*4-(i-1)*2+dir,ICE_GRAY,12);
			}
		}
	}
}




//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);

	loop(30)
	{
		DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
		yield;
	}

	CloseScript(GetOwnScriptID());
}
