
#ScriptVersion[3]
#Title["DoremyEnd"]
#Text["DoremyEnd"]
#Player[DEFAULT]
#System["./system/Default_System.txt"]
#Background["./BG.txt"]
#Player["./MoF_Reimu/Reimu.txt"]
#include"./Functions/Index.txt"
#include"./SetBoss.txt"
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"


let objBoss;
let GCSD=GetCurrentScriptDirectory~"";
let enemy;
let bSpell=false;
let stgx=GetStgFrameWidth()/2;
let stgy=GetStgFrameHeight()/2;
let idle = true;
let atk = false;
let fog = 0;
let objScene=GetEnemyBossSceneObjectID();
let color = [0,0];
@Initialize
{
SetBoss("Doremy",false);
}

@MainLoop
{
	ObjEnemy_SetIntersectionCircleToPlayer(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),25);
	ObjEnemy_SetIntersectionCircleToShot(objBoss,ObjMove_GetX(objBoss),ObjMove_GetY(objBoss),26);
	yield;

}

@Event
{
	alternative(GetEventType())
	case(EV_REQUEST_LIFE)
	{
		SetScriptResult(0);
	}
	case(EV_REQUEST_TIMER)
	{
		SetScriptResult(0);
	}
		case(EV_REQUEST_SPELL_SCORE)
	{
		SetScriptResult(35000000);
	}
}

//----------------------------------------------------
task mainTask{
	ObjMove_SetDestAtWeight(objBoss,stgx,120,10,10);
	magiccircle(objBoss,1,-1);
	}

//----------------------------------------------------


//----------------------------------------------------



//----------------------------------------------------


task TEnd{
	while(ObjEnemy_GetInfo(objBoss,INFO_LIFE)>0){yield;}
		let color = GetColor("PURPLE");
		ClearBullet(120,10);
ExCircle(GetEnemyX,GetEnemyY,0.05,5);
ExCircle(GetEnemyX-30,GetEnemyY,0.05,100);
ExCircle(GetEnemyX+30,GetEnemyY,0.05,100);
ExCircle(GetEnemyX,GetEnemyY-30,0.05,100);
ExCircle(GetEnemyX,GetEnemyY+30,0.05,100);
loop(10){yield;}
		ObjMove_SetPosition(objBoss,stgx,-1000);
		PlaySound("enemoff",100,0);
		MapleExplode(stgx,150,1.5,"PINK");
		MapleExplode(stgx,150,2,"AQUA");
		descent(i in 0..30){
		Maple(stgx,150,1+i/30,rand(0,360),color[0],color[1],color[2]);
		yield;}

			wait(60);
		EndBoss(0);
		yield;
		CloseScript(GetOwnScriptID());
}

task ExCircle(x,y,sc,dtime){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let timer = 0;
let s = 0;


let Target = GetCurrentScriptDirectory~"./Effect03.png";
let mx = ObjRender_GetX(obj);
let my = ObjRender_GetY(obj);


	Obj_SetRenderPriorityI(obj, 79);
	ObjPrim_SetTexture(obj, Target);

	ObjRender_SetBlendType(obj, BLEND_INV_DESTRGB);

	ObjSprite2D_SetSourceRect(obj, 0, 0, 512, 512);

        ObjSprite2D_SetDestCenter(obj);
        ObjRender_SetScaleXYZ(obj, s, s, s);
ObjRender_SetPosition(obj,x,y,0);
loop{
timer++;
        s+=sc;
        ObjRender_SetScaleXYZ(obj, s, s, s);

        if(timer == dtime){
        Obj_Delete(obj);
        break;
        }
        yield;
        }
        }