#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Boss Fight"]
#Text[""]
#Image[""]
#Background[".\background.txt"]
#BGM[""]
#System[".\Parsee system\System\Parsee_System.txt"]
SetCommonData("dat",0);
let ss = GetCurrentScriptDirectory~"./Sounds/Music.mp3";
let ss2 = GetCurrentScriptDirectory~"./Sounds/lastw.mp3";
let objmusic = ObjSound_Create;
let objmusic2 = ObjSound_Create;

let bgam = GetCurrentScriptDirectory ~ "./Sounds/st.mp3" ;
let bgam2 = GetCurrentScriptDirectory ~ "./Sounds/lastw.mp3" ;
let sbg=GetCurrentScriptDirectory~"bgg.jpg";

@Initialize{
	ObjSound_Load(objmusic,ss);
	ObjSound_Load(objmusic2,ss2);
	TPlural();
	LoadSound(bgam);
	LoadSound(bgam2);
	bak;
	bak2;
	}

	let vv=0;
	let hhh=0;
	
	task bak{
	
	
	SetPlayerLife(9);
	
	
	//
	
	
	
	//
	
	
	
	
	
	

	
	
	
	}
	
	
	
	
@Event{
	alternative(GetEventType())
	case(EV_PAUSE_ENTER){
		ObjSound_SetRestartEnable(objmusic,true);
		ObjSound_Stop(objmusic);}
	case(EV_PAUSE_LEAVE){
		ObjSound_Play(objmusic);
		ObjSound_SetRestartEnable(objmusic,false);}}
	
	task bak2{
	
	
	
	
let bg1q=ObjPrim_Create(OBJ_SPRITE_2D);
bax(bg1q);
ObjPrim_SetTexture(bg1q,sbg);
ObjSprite2D_SetSourceRect(bg1q,0,0,1000,800);
ObjRender_SetAlpha(bg1q,255);
ObjSprite2D_SetDestCenter(bg1q);
ObjRender_SetPosition(bg1q,GetStgFrameWidth/2+150,230,0);
	
	
	
task bax(vv){

while(!Obj_IsDeleted(vv)){
yield;
ObjRender_SetAlpha(bg1q,255);

Obj_SetRenderPriorityI(bg1q,20);
ObjRender_SetAngleZ(vv,1-cos(hhh));
ObjRender_SetScaleXYZ(vv,1,1,1);
hhh+=1;
}
}


	
	
	
	}
	
@MainLoop{yield;}

@Finalize{}


task TPlural{
ObjSound_Play(objmusic);
	let dir = GetCurrentScriptDirectory();
	
	SetCommonData("dat",0);
	SetCommonData("sos",0);
	
	let obj = ObjEnemyBossScene_Create();
	
	ObjEnemyBossScene_Add(obj, 0, dir ~ "Non1.txt");
	ObjEnemyBossScene_Add(obj, 0, dir ~ "Sp1.txt");
	
	ObjEnemyBossScene_Add(obj, 1, dir ~ "Non2.txt");
	ObjEnemyBossScene_Add(obj, 1, dir ~ "Sp2.txt");
	
	ObjEnemyBossScene_Add(obj, 2, dir ~ "Non3.txt");
	ObjEnemyBossScene_Add(obj, 2, dir ~ "Sp3.txt");
	
	ObjEnemyBossScene_Add(obj, 3, dir ~ "Non4.txt");
	ObjEnemyBossScene_Add(obj, 3, dir ~ "Sp4.txt");
	
	ObjEnemyBossScene_Add(obj, 4, dir ~ "Sp5.txt");
	
	
	
			  
	ObjEnemyBossScene_LoadInThread(obj);
	ObjEnemyBossScene_Regist(obj);
	
	while(!Obj_IsDeleted(obj)){
	
	PlayBGM(bgam,0,379);
	if(GetCommonData("dat",1)){yield;
	loop(100){

	ObjSound_SetVolumeRate(objmusic,ObjSound_GetVolumeRate(objmusic)-1);yield;}
	loop(185){yield;}
	
	yield;
	break;
	
	}
	
	
	
	
	yield;}

	while(!Obj_IsDeleted(obj)){yield;}
		
	CloseScript(GetOwnScriptID());}