
#ScriptVersion[3]
#Title["Shou!"]
#Text[" Difficulty : Hard(****)                "]
#Background["./BG.txt"]
#include"./Shot/ZUNShot_Const.txt"
#include"./system/Default_Effect.Txt"
#System["./system/Default_System.txt"]
let dirCurrent = GetCurrentScriptDirectory();
let MainSTG = GetCurrentScriptDirectory();
let song = ObjSound_Create;
@Initialize{
	if(GetCommonData("ItemStart",0)==0){StartItemScript(dirCurrent ~"Item.txt");}
	SetCommonData("Fight",0);
	SetCommonData("Effect",2);
	TPlural;
	//DifficultyMenu;
	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/ZUNShot.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;
}

task EffectMenu {
	let selection = 0;
	loop(60){
	yield;
	}
	let menuItems = 3;
	let press = 0;
	ascent(i in 0..3){
	DrawNumber(i);
	}
	DrawText(10,30,18,"RED","Choose the quality of effects that you want.");
	DrawText(50,60,18,"RED","Higher value means better effects.");
	DrawText(60,90,15,"ORANGE","(Use up/down arrow keys to select.)");
	DrawText(120,120,15,"ORANGE","(Press X to choose.)");
	loop(60){yield;}
	while(press==0){
    if(GetVirtualKeyState(VK_UP)==KEY_PUSH){ 
	selection--;
	PlaySound("select",100,0);
	}
    if(GetVirtualKeyState(VK_DOWN)==KEY_PUSH){
	selection++;
	PlaySound("select",100,0);
	}
    if(GetVirtualKeyState(VK_BOMB)==KEY_PUSH){
	PlaySound("ok",100,0);
	press++;
	}
    if(selection >= menuItems){ selection = 0; }
    if(selection < 0){ selection = menuItems-1; }
	yield;
	}
	SetCommonData("Fight",1);
	SetCommonData("Effect",selection);
	TPlural;
		task DrawNumber(num){
		let objTxt=ObjText_Create;
		let alpha = 0;
		ObjText_SetText(objTxt,IntToString(num));
		ObjText_SetFontSize(objTxt,50);
		ObjText_SetFontColorTop(objTxt,255,255,255);
		ObjText_SetFontColorBottom(objTxt,255,255,255);
		ObjText_SetFontBorderWidth(objTxt,1);
		ObjText_SetFontBorderType(objTxt,BORDER_FULL);
		ObjText_SetFontBorderColor(objTxt,255,0,0);
		ObjText_SetMaxWidth(objTxt,100);
		ObjText_SetMaxHeight(objTxt,100);
		ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_LEFT);
		ObjRender_SetPosition(objTxt,384/2-10,150+num*90,0);
			while(press==0){
			if(alpha<255){alpha+=10;}
			ObjRender_SetAlpha(objTxt,alpha);
			if(selection==num){ObjText_SetFontBorderColor(objTxt,255,0,0);}
			else{ObjText_SetFontBorderColor(objTxt,0,0,255);}
			yield;
			}
			Obj_Delete(objTxt);
		}
		
		task DrawText(x,y,size,colort,text){
			let objTxt=ObjText_Create;
			let color = ReturnColor(colort);
			let alpha = 0;
			ObjText_SetText(objTxt,text);
			ObjText_SetFontSize(objTxt,size);
			ObjText_SetFontColorTop(objTxt,255,255,255);
			ObjText_SetFontColorBottom(objTxt,255,255,255);
			ObjText_SetFontBorderWidth(objTxt,1);
			ObjText_SetFontBorderType(objTxt,BORDER_FULL);
			ObjText_SetFontBorderColor(objTxt,color[0],color[1],color[2]);
			ObjText_SetMaxWidth(objTxt,500);
			ObjText_SetMaxHeight(objTxt,100);
			ObjText_SetHorizontalAlignment(objTxt,ALIGNMENT_LEFT);
			ObjRender_SetPosition(objTxt,x,y,0);
			while(press==0){
			if(alpha<255){alpha+=10;}
			ObjRender_SetAlpha(objTxt,alpha);
			yield;
			}
			Obj_Delete(objTxt);
			}
}

task TPlural
{
	let dir=GetCurrentScriptDirectory();
	let obj=ObjEnemyBossScene_Create();
	Sound(dir~"Shou.mp3");
	ObjEnemyBossScene_Add(obj,0,dir~"S1.txt");
	ObjEnemyBossScene_Add(obj,0,dir~"SP1.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"S2.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"SP2.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"S3.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"SP3.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"S4.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"SP4.txt");
	ObjEnemyBossScene_Regist(obj);
	SetForbidPlayerShot(false);
	loop(30){yield;}
	SetForbidPlayerSpell(false);
	while(!Obj_IsDeleted(obj))
	{
		yield;
	}
	CloseScript(GetOwnScriptID());
}

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