//#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Intro"]
#include "./sharedfuncJames.dnh"



let objBoss;
let width = 384;
let height = 448;
let life = 1;
let scene = GetEnemyBossSceneObjectID();

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


@Initialize{
    objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
    ObjEnemy_Regist(objBoss);
	
	anim;
	TFinalizeFade;
	
	
    ObjMove_SetDestAtFrame(objBoss, width/2, 3*height/10, 60);
	Main;
}


@MainLoop{
    ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32); 
    ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 28);
    yield;
}

task anim{
    let img = GetCurrentScriptDirectory() ~ "../img/NonSpell.png";
	ObjPrim_SetTexture(objBoss, img);
	ObjSprite2D_SetSourceRect(objBoss, 316, 70, 436, 410); 
	ObjSprite2D_SetDestRect(objBoss, -25, -70, 25, 70);
}


task Main{
    Indicator(objBoss);
    SetForbidPlayerShot(true);
    ObjEnemy_SetDamageRate(objBoss, 0,0);
    wait(60);
	text("Welcome to the new game in[r]The Warwick Touhou Project!", 150);
	wait(150);
	text("My name is James Robinson[r] and yours doesn't matter.", 150);
	wait(150);
	text("Now DIE!!!", 150);
	wait(150);
	ObjEnemy_SetLife(objBoss, 0);
}


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