#“Œ•û’e–‹•—[Stage]
#ScriptVersion[3]
#Title["Kanako!"]
#Text["Jam By TalosMistake"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
let dir = GetCurrentScriptDirectory();
let dirCurrent = GetCurrentScriptDirectory();
let song = ObjSound_Create;
let MainSTG = GetCurrentScriptDirectory();

@Initialize
{
	SetPlayerLife(6);
	TStage;
	StartScript(LoadScriptInThread(dir ~ "BG.txt"));
	LoadTexture(dirCurrent~"img/Cutin.png");
	LoadTexture(dirCurrent~"img/effbreak.png");
	LoadTexture(dirCurrent~"img/Marisa1.png");
	LoadTexture(dirCurrent~"img/stg3bg1.png");
	LoadTexture(dirCurrent~"img/boss.png");
	LoadTexture(dirCurrent~"Shot/AllStarShot.png");
	LoadTexture(dirCurrent~"system/img/front01.png");
	LoadTexture(dirCurrent~"system/img/front00.png");
	LoadTexture(dirCurrent~"img/Dot.png");
	LoadTexture(dirCurrent~"img/Cutin.png");
	LoadTexture(dirCurrent~"img/cdbg05a.png");
	LoadTexture(dirCurrent~"img/cdbg05b.png");
}

@Event
{
	alternative(GetEventType())
	case(EV_PAUSE_ENTER)
	{
		ObjSound_Stop(song);
	}
	case(EV_PAUSE_LEAVE)
	{
		ObjSound_Play(song);
	}
}

@MainLoop
{
	yield;
}

@Finalize
{
}

task TStage
{
	let path;
	let idScript;	
	Sound(dir ~ "boss6.mp3");
	path = dir ~ "Kanako.txt";
	idScript = LoadScriptInThread(path);
	loop(120){yield;};
	StartScript(idScript);
		while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
	{
		yield;
	}
	loop(240){yield;}
	
	CloseStgScene();
}

function Sound(path){
	ObjSound_Load(song,path);
	ObjSound_SetSoundDivision(song, SOUND_BGM);
	ObjSound_SetRestartEnable(song, true);
	ObjSound_SetLoopEnable(song, true);
	ObjSound_SetLoopTime(song, 0,600);
	ObjSound_Play(song);
	ObjSound_SetVolumeRate(song,100);
	}
	
task StopS(obj){
	descent(i in 0..100){
	ObjSound_SetVolumeRate(song,i);
	loop(2){yield;}
	}
	ObjSound_Stop(song);
	}
	
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);
}

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];}
	}

