#include "./shot/AllStarShot_Const.txt"
#include "./resources/BloomFX.txt"
#include "./resources/Gizmo's Sprite Library/GizmoSpriteLibrary.txt"
#include "./DLS's System.txt"

let objBoss;
let objScene = GetEnemyBossSceneObjectID();
let shot_sound = GetCurrentScriptDirectory ~ "./SFX/se_shot.wav";
let charm_sound = GetCurrentScriptDirectory ~ "./SFX/se_charm.wav";

let choose = ObjText_Create;

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){
		SetScriptResult(1);
	}
}

@Initialize
{
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);

	CallWeatherBackground(5);

	ObjEnemy_SetDamageRate(objBoss, 0, 0);

	renderYuukaPoFV(objBoss, 1);

	LoadSound(shot_sound);
	LoadSound(charm_sound);

	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);

	TFinalize;
	TaskManager;
}

task TaskManager
{
	ObjMove_SetX(objBoss, 320);
	ObjMove_SetY(objBoss, -60);
	SetCommonData("mode", 1);
	ChooseMode;
}

task ChooseMode
{
	let objTextA = ObjText_Create;
	let objTextAA = ObjText_Create;
	let objTextB = ObjText_Create;
	let objTextC = ObjText_Create;

	ObjText_SetText(objTextA, "Choose Weather Mode!");
	ObjText_SetFontType(objTextA, "Arial");
	ObjText_SetFontColorTop(objTextA, 255, 255, 255);
	ObjText_SetFontColorBottom(objTextA, 255, 65, 65);
	ObjText_SetFontBorderWidth(objTextA, 2);
	ObjText_SetFontBorderType(objTextA, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objTextA, 0, 0, 0);
	ObjText_SetLinePitch(objTextA, 4);
	ObjText_SetSidePitch(objTextA, 0);
	ObjText_SetFontSize(objTextA, 18);
	ObjRender_SetX(objTextA, 200);
	ObjRender_SetY(objTextA, 90);

	ObjText_SetText(objTextAA, "Go upwards to choose Normal Weather, downwards to choose Scarlet Weather.[r]Press Bomb (X) to confirm.");
	ObjText_SetFontType(objTextAA, "Arial");
	ObjText_SetFontColorTop(objTextAA, 255, 255, 255);
	ObjText_SetFontColorBottom(objTextAA, 255, 65, 65);
	ObjText_SetFontBorderWidth(objTextAA, 2);
	ObjText_SetFontBorderType(objTextAA, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objTextAA, 0, 0, 0);
	ObjText_SetLinePitch(objTextAA, 4);
	ObjText_SetSidePitch(objTextAA, 0);
	ObjText_SetFontSize(objTextAA, 15);
	ObjRender_SetX(objTextAA, 25);
	ObjRender_SetY(objTextAA, 110);

	ObjText_SetText(objTextB, "Normal Weather - Normal gameplay with no modifications.");
	ObjText_SetFontType(objTextB, "Arial");
	ObjText_SetFontColorTop(objTextB, 255, 255, 255);
	ObjText_SetFontColorBottom(objTextB, 65, 255, 65);
	ObjText_SetFontBorderWidth(objTextB, 2);
	ObjText_SetFontBorderType(objTextB, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objTextB, 0, 0, 0);
	ObjText_SetLinePitch(objTextB, 4);
	ObjText_SetSidePitch(objTextB, 0);
	ObjText_SetFontSize(objTextB, 15);
	ObjRender_SetX(objTextB, 70);
	ObjRender_SetY(objTextB, 180);

	ObjText_SetText(objTextC, "Scarlet Weather - Weather affects your gameplay,[r]ranging from giving free lives to removing your deathbomb window.");
	ObjText_SetFontType(objTextC, "Arial");
	ObjText_SetFontColorTop(objTextC, 255, 255, 255);
	ObjText_SetFontColorBottom(objTextC, 255, 65, 255);
	ObjText_SetFontBorderWidth(objTextC, 2);
	ObjText_SetFontBorderType(objTextC, BORDER_SHADOW);
	ObjText_SetFontBorderColor(objTextC, 0, 0, 0);
	ObjText_SetLinePitch(objTextC, 4);
	ObjText_SetSidePitch(objTextC, 0);
	ObjText_SetFontSize(objTextC, 15);
	ObjRender_SetX(objTextC, 70);
	ObjRender_SetY(objTextC, 210);

	ObjText_SetText(choose, ">>>");
	ObjText_SetFontType(choose, "Verdana");
	ObjText_SetFontColorTop(choose, 255, 255, 255);
	ObjText_SetFontColorBottom(choose, 255, 65, 65);
	ObjText_SetFontBorderWidth(choose, 2);
	ObjText_SetFontBorderType(choose, BORDER_SHADOW);
	ObjText_SetFontBorderColor(choose, 0, 0, 0);
	ObjText_SetLinePitch(choose, 4);
	ObjText_SetSidePitch(choose, 1);
	ObjText_SetFontSize(choose, 15);
	ObjRender_SetX(choose, 20);
	ObjRender_SetY(choose, 180);
}

task TFinalize
{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
	Obj_Delete(objBoss);
	SetAutoDeleteObject(true);
	CloseScript(GetOwnScriptID());
	return;
}

@MainLoop
{
	if(GetPlayerY > 360)
	{
		ObjRender_SetY(choose, 210);
		SetCommonData("mode", 1);
	}
	if(GetPlayerY < 360)
	{
		ObjRender_SetY(choose, 180);
		SetCommonData("mode", 2);
	}
	if(GetVirtualKeyState(VK_SPELL) == KEY_PUSH || GetVirtualKeyState(VK_SPELL) == KEY_HOLD)
	{
		ObjEnemy_AddLife(objBoss, -1);
	}
        yield;
}

function GetCenterX
{
	return GetStgFrameWidth/2;
}
function GetCenterY
{
	return GetStgFrameHeight/2;
}
function wait(n)
{
	loop(n){yield;}
}