//#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["BGMFade2"]
#include "./sharedfuncMario.dnh"

let objBoss;
let width = 384;
let height = 448;
let life = 1;


@Event{                                
    alternative(GetEventType())       
    case(EV_REQUEST_LIFE){           
        SetScriptResult(life); 
    }
    case(EV_REQUEST_TIMER){        
        SetScriptResult(12);
    }
}


@Initialize{                                  
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);   
    ObjEnemy_Regist(objBoss);
	animNon(objBoss);
	TFinalizeNon(objBoss);
	
    MainTask;
}



@MainLoop{     
    ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);            // boss hurtbox (what the player must shoot)
    ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 28);          // boss hitbox (what the player must avoid)
	yield;
}

task MainTask{
    SetForbidPlayerShot(true);
    Indicator(objBoss);
    ObjEnemy_SetDamageRate(objBoss, 0, 0);
	NotifyEventAll(EV_USER_STAGE + 3, 0);
	wait(30);
	text("Oh![r] You are still standing!", 150);
	wait(210);
	NotifyEventAll(EV_USER_STAGE + 4, 0);
	text("No matter.[r]You've taken too much[r]of my time!", 150);
	wait(190);
	text("Feel my wrath!!!", 150);
	wait(180);
	ObjEnemy_SetLife(objBoss, 0);
}	



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