#ScriptVersion[3]
#Title[""]
#Text[""]
#Background["./BG22hu.txt"]
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#System["./system/Default_System.txt"]
let dirCurrent = GetCurrentScriptDirectory();
let MainSTG = GetCurrentScriptDirectory();
@Initialize{
	if(GetCommonData("ItemStart",0)==0){StartItemScript(dirCurrent ~"Item.txt");}
	SetCommonData("Fight",0);
	SetCommonData("Effect",2);
	SetCommonData("Scroll",1);
	loop(1){yield;}
	TPlural;
}

@Event
{
	alternative(GetEventType())
}

@MainLoop{
	yield;
}

task TPlural
{
	SetShotAutoDeleteClip(64,64,64,64);
	//SetStgFrame(0, 0, 640, 480, 0, 20);
	//SetPlayerClip( 0, 27, 640, 430 );
	let dir=GetCurrentScriptDirectory();
	let obj=ObjEnemyBossScene_Create();
	SetForbidPlayerShot(false);
	SetForbidPlayerSpell( false );
	//NotifyEventAll(EV_SET_SONG,1);
	ObjEnemyBossScene_Add(obj,0,dir~"YaorochiNon1.txt");
	ObjEnemyBossScene_Add(obj,0,dir~"YaorochiSpell1.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"YaorochiNon2.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"YaorochiSpell2.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"YaorochiSpell3.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"YaorochiSpell4.txt");
	ObjEnemyBossScene_Add(obj,4,dir~"SaragimaruEnd.txt");
	ObjEnemyBossScene_Regist(obj);
	loop(30){yield;}
	while(!Obj_IsDeleted(obj))
	{
		yield;
	}
	CloseScript(GetOwnScriptID());
}
	
task PlaySound(str,v,w){
	let s = ObjSound_Create;
	if(str == "select"){ObjSound_Load(s,MainSTG~"sound/select.wav");}
	if(str == "ok"){ObjSound_Load(s,MainSTG~"sound/ok.wav");}
	loop(w){yield;}
	ObjSound_SetSoundDivision(s,SOUND_SE);
	ObjSound_SetVolumeRate(s,v);
	ObjSound_Play(s);
}

let musicplayer = false;
task MusicPlay
{
	loop
	{
		let music1 = ObjSound_Create;
		music1 = ObjSound_Create;
		ObjSound_Load(music1, GetCurrentScriptDirectory ~ "LenenBGM/YaorochiTheme.ogg");
		ObjSound_SetSoundDivision(music1, SOUND_BGM);
		ObjSound_SetRestartEnable(music1, true);
		ObjSound_SetLoopEnable(music1, false);	
		//ObjSound_SetLoopSampleCount(music1,1499633,5631073);		
		ObjSound_Play(music1);
		
		ObjSound_SetVolumeRate(music1,50);
		while(!musicplayer)
		{
	
			yield;
		}
		Obj_Delete(music1);
		while(musicplayer)
		{
			yield;
		}
	}
}

function ReturnColor(type){
	if(type=="RED"){return [255,0,0];}
	if(type=="ORANGE"){return [255,128,0];}
	if(type=="YELLOW"){return [255,255,0];}
	if(type=="GREEN"){return [0,255,0];}
	if(type=="BLUE"){return [0,0,255];}
	if(type=="PURPLE"){return [255,0,255];}
	if(type=="WHITE"){return [255,255,255];}
	}
