#東方弾幕風[Single]
#ScriptVersion[3]
#Title["Dialogue2"]
#Text["a"]
#System["./default_system/Default_System.txt"]
#Background["./default_System/Default_Background.txt"]
#include"./default_system/Default_Index.txt"

let objBoss;
	
let BossX;
let BossY;

@Initialize {
	SetPlayerClip(126, 12, 510, 468);
	objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(objBoss);
	
	ObjMove_SetPosition(objBoss, -50, -50);
	//ObjMove_SetDestAtWeight(objBoss, GetStgFrameWidth/2, GetStgFrameHeight/2-100, 5, 4);

	Initialization;
	
	Main;
	end;
} 

task Initialization{
	RenderGaraiya(objBoss);
	RenderGaraiyaNoShikigami(objBoss);
	MagicRing(objBoss);
	HitSound(objBoss,60,500);
	TimerCountdown;
	SetArmor(objBoss, [90, 80], 180);
	EnemyMarker(objBoss);
}

@Event { 
	alternative(GetEventType())
	case(EV_REQUEST_LIFE){SetScriptResult(1);}
	case(EV_REQUEST_TIMER){SetScriptResult(60);}
	//case(EV_REQUEST_SPELL_SCORE){SetScriptResult(10000);}
	//case(EV_REQUEST_IS_DURABLE_SPELL){SetScriptResult(true);}
	//case(EV_REQUEST_IS_LAST_SPELL){SetScriptResult(true);}
} 

@MainLoop {
	BossX = ObjMove_GetX(objBoss);
	BossY = ObjMove_GetY(objBoss);
	SetCommonData("BossX", BossX);
	SetCommonData("BossY", BossY);
	yield;
} 

@Finalize {
} 

task ColorChange{
wait(120);
ascent(i in 0..64){
SetCommonData("StgFrameColor", [255-i*4, 255, 255-i*4]);
yield;
}
}

task GrayToRed{
ascent(i in 0..32){
SetCommonData("StgFrameColor", [255, 255-i*8, 255-i*8]);
yield;
}
}

task RedToGreen{
ascent(i in 0..32){
SetCommonData("StgFrameColor", [255-i*8, 0+i*8, 0]);
yield;
}
}

task Main { 
SetCommonData("BackgroundSpeed", 4);
wait(120);

GrayToRed;
SetText(GetPlayerX, GetPlayerY, 2,0,0,0,"I think that's that...",90,65, true);
SetText(GetPlayerX, GetPlayerY, 2,0,0,0,"I'll just go back to the Pagoda and take a rest.",200,65, true);

ObjEnemy_SetLife(objBoss, 0);
}

task end{
    while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
	//NotifyEvent(GetStageID, EV_USER_STAGE, [true, true, true, false, false, false]); //smexplosion, smparticles, items, bigexplosion, bigparticles, shake+slow
    Obj_Delete(objBoss);
    DeleteShotAll(TYPE_ALL, TYPE_ITEM);
    SetAutoDeleteObject(true);
    CloseScript(GetOwnScriptID());
} 