//e[Single]
#ScriptVersion[3]
#ID["DT_31_ALICE_N00"]
//System["script/default_system/Default_System.txt"]
#Title["ALICE_N00"]
#Text[""]
//Image[""]
//Background["script/default_system/Default_Background_IceMountain.txt"]
//Player[]

#include "./../../cmn/common.txt"
#include "./../../cmn/shotConst.txt"
#include "./../../cmn/Effect.txt"
#include "./../../cmn/boss/commonBossFunc.txt"
#include "./../../cmn/commonFunc.txt"
#include "./../../cmn/lib/lib_anime_Alice.txt"

let objEnemy;	//GIuWFNg
let pathDot = GetCurrentScriptDirectory() ~ "./../../img/alice_dot.png";
//let pathCutin = GetCurrentScriptDirectory() ~ "./../../img/alice_cutin.png";
let pathTimer = GetCurrentScriptDirectory() ~ "./../../se/timer.wav";
let pathShot = GetCurrentScriptDirectory() ~ "./../../se/shot0.wav";

@Loading{
	if(!IsCommonDataAreaExists(nsStage)){
		LoadTexture(pathDot);
//		LoadTexture(pathCutin);
		LoadSound(pathTimer);
		LoadSound(pathShot);
	}
}

@Initialize{
	objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objEnemy);
	
	ObjEnemy_SetDamageRate(objEnemy, 0, 0);
	SetShotAutoDeleteClip(64,64,64,64);
	
	InitializeAction(objEnemy, pathDot);
	Render();
//	BackGround(pathCutin, 450, 600);
	Schedule();
}

@MainLoop{
	let ex = ObjMove_GetX(objEnemy);
	let ey = ObjMove_GetY(objEnemy);
	ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//蔻(e)o^
	ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//蔻(̓)o^
	
	yield;
}

@Event{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(2500);	//Ctݒ
	}
	case(EV_REQUEST_TIMER){
		let timerBoss = 60;
		SetScriptResult(timerBoss);	//Ԑݒ
		TimerSE(timerBoss);
	}
	case(EV_REQUEST_SPELL_SCORE){
//		SetScriptResult(10);	//XyJ[h{[iXݒ
//		T_SpellCardBonus(50000);
	}
//	case(EV_REQUEST_IS_DURABLE_SPELL){
//		SetScriptResult(true);	//ϋvXyJݒ
//	}
	others{}
}

@Finalize{}

task Schedule(){
	ObjMove_SetX(objEnemy, GetStgFrameWidth()+64);
	ObjMove_SetY(objEnemy, GetStgFrameHeight()/2);
	ObjMove_SetDestAtFrame(objEnemy, GetStgFrameWidth()-100, GetStgFrameHeight()/2, 60);
	SetAction(ACT_MOVE, 60);
	Wait(60);
	
//	ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID());
//	CutIn(pathCutin,180,191,450,600);
//	SetAction(ACT_SPELL,120);
//	Wait(180);
	
	Fire();
	End(-1);
	
	Wait(30);
	SetDamageRateType();
}

//U
task Fire(){
	let ang = rand(0,360);
	let way = 7;
	let clr = 0;
	let clrs = [S_RED,S_ORANGE,S_YELLOW,S_GREEN,S_BGREEN,S_BLUE,S_RPURPLE];
	
	Move();
	
	SetAction(ACT_SHOT_A,36);
	Wait(12);
	loop(7){
		Doll(ang,clrs[clr]);
		ang += (360/way);
		clr++;
	}
}

task Move(){
	loop{
		Wait(60);
		SetAction(ACT_MOVE,60);
		SetMoveBoss(60);
		Wait(60);
	}
}

task Doll(let ang,let clr){
	let shot = CreateShotA1(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy),3,ang,S_DOLL+clr,0);
	ObjShot_SetSpellResist(shot,true);
	Shot_Modify(shot);
	
	Wait(30);
	ObjMove_SetSpeed(shot,0);
	Wait(30);
	
	let way = 17;
	let angB = 0;
	let obj;
	loop{
		if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0){	return;	}
		PlaySE(pathShot);
		angB = 180;
		loop(way){
			obj = CreateShotA1(ObjMove_GetX(shot),ObjMove_GetY(shot),3,angB,S_SCALE_S+clr,0);
			Shot_Modify(obj);
			angB += (360/way);
		}
		Wait(30);
		if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0){	return;	}
		PlaySE(pathShot);
		angB = GetAngleToPlayer(shot);
		loop(way){
			obj = CreateShotA1(ObjMove_GetX(shot),ObjMove_GetY(shot),3,angB,S_SCALE_S+clr,0);
			Shot_Modify(obj);
			angB += (360/way);
		}
		Wait(30);
	}
}
