
#ScriptVersion[3]
#Title["Doremy Plural"]
#Text["              "]
#Background["./BG.txt"]
#include"./Shot/AllStarShot_Const.dnh"
#include"./system/Default_Effect.Txt"
#System["./system/Default_System.txt"]
let dirCurrent = GetCurrentScriptDirectory();
let MainSTG = GetCurrentScriptDirectory();
@Initialize{
	if(GetCommonData("ItemStart",0)==0){StartItemScript(dirCurrent ~"Item.txt");}
	SetCommonData("Fight",0);
	SetCommonData("Effect",2);
	SetCommonData("Scroll",0);
	TitleOut;
	loop(1){yield;}
	TPlural;
	LoadTexture(dirCurrent~"img/Cutin.png");
	LoadTexture(dirCurrent~"img/effbreak.png");
	LoadTexture(dirCurrent~"img/Marisa1.png");
	LoadTexture(dirCurrent~"img/stg3bg1.png");
	LoadTexture(dirCurrent~"img/boss.png");
	LoadTexture(dirCurrent~"Shot/ZUNShot.png");
	LoadTexture(dirCurrent~"system/img/front01.png");
	LoadTexture(dirCurrent~"system/img/front00.png");
	LoadTexture(dirCurrent~"img/Dot.png");
	LoadTexture(dirCurrent~"img/Cutin.png");
	LoadTexture(dirCurrent~"img/cdbg05a.png");
	LoadTexture(dirCurrent~"img/cdbg05b.png");
}

@Event
{
	alternative(GetEventType())
}

@MainLoop{
	yield;
}

task TPlural
{
	let dir=GetCurrentScriptDirectory();
	let obj=ObjEnemyBossScene_Create();
	ObjEnemyBossScene_Add(obj,0,dir~"Copy of DoremyNon1.txt");
	ObjEnemyBossScene_Add(obj,0,dir~"Copy of DoremySpell1.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"Copy of DoremyNon2.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"Copy of DoremySpell2.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"Copy of DoremyNon3.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"Copy of DoremySpell3.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"Copy of DoremyNon4.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"Copy of DoremySpell4.txt");
	ObjEnemyBossScene_Add(obj,4,dir~"Copy of DoremySpell5.txt");
	ObjEnemyBossScene_Add(obj,4,dir~"DoremyEnd.txt");
	ObjEnemyBossScene_Regist(obj);
	SetForbidPlayerShot(false);
	loop(30){yield;}
	SetForbidPlayerSpell(false);
	while(!Obj_IsDeleted(obj))
	{
		yield;
	}
	CloseScript(GetOwnScriptID());
}
	
task PlaySound(str,v,w){
	let s = ObjSound_Create;
	if(str == "select"){ObjSound_Load(s,MainSTG~"sound/select.wav");}
	if(str == "ok"){ObjSound_Load(s,MainSTG~"sound/ok.wav");}
	loop(w){yield;}
	ObjSound_SetSoundDivision(s,SOUND_SE);
	ObjSound_SetVolumeRate(s,v);
	ObjSound_Play(s);
}

task TitleOut{
	let stgimg2 = GetCurrentScriptDirectory ~ "drN.png";
	let stgimg3 = GetCurrentScriptDirectory ~ "drB.png";
	let stgimg = GetCurrentScriptDirectory ~ "drN.png";
	let StageStrip = CreateEffectObject(224,210,stgimg3,"ALPHA",0,0,512,512);
	Obj_SetRenderPriority(StageStrip,0.22);
	ObjRender_SetScaleXYZ(StageStrip,1,0.06,0.06);
	let StageName = CreateEffectObject(205,205,stgimg2,"ALPHA",0,0,482,100);
	ObjRender_SetScaleXYZ(StageName,0.65,0.65,0.65);
	let StageName2 = CreateEffectObject(245,265,stgimg2,"ALPHA",0,100,462,200);
	ObjRender_SetScaleXYZ(StageName2,0.65,0.65,0.65);
	let StageName3 = CreateEffectObject(245,305,stgimg,"ALPHA",0,200,442,280);
	ObjRender_SetScaleXYZ(StageName3,0.55,0.55,0.55);
	let StageD = CreateEffectObject(220,150,stgimg,"ALPHA",0,280,462,340);
	ObjRender_SetScaleXYZ(StageD,0.6,0.6,0.6);
	let StageT = CreateEffectObject(225,330,stgimg2,"ALPHA",0,340,442,420);
	ObjRender_SetScaleXYZ(StageT,0.65,0.65,0.65);
	//What happens ingame
	Move(StageName2,"LEFT");
	Move(StageName,"RIGHT");
	Move(StageName3,"RIGHT");
	Move(StageD,"LEFT");
	Move(StageT,"LEFT");
	ascent(i in 0..61){
	ObjRender_SetScaleY(StageStrip,i/60);
	ObjRender_SetAlpha(StageName3,i*255/60);
	ObjRender_SetAlpha(StageD,i*255/60);
	ObjRender_SetAlpha(StageT,i*255/60);
	ObjRender_SetAlpha(StageName,i*255/60);
	ObjRender_SetAlpha(StageName2,i*255/60);

	yield;
	}
	loop(200){yield;}
	descent(i in 0..61){
	ObjRender_SetScaleY(StageStrip,i/60);
	ObjRender_SetAlpha(StageName,i*255/60);
	ObjRender_SetAlpha(StageName2,i*255/60);
	ObjRender_SetAlpha(StageD,i*255/60);
	ObjRender_SetAlpha(StageT,i*255/60);
	ObjRender_SetAlpha(StageName3,i*255/60);
	yield;
	}
	Obj_Delete(StageStrip);
	Obj_Delete(StageName);
	Obj_Delete(StageName2);
	Obj_Delete(StageD);
	Obj_Delete(StageT);
	Obj_Delete(StageName3);

	//Movement Tasks
	task MagicSpin(objs,angsp){
	let ang = 0;
	while(!Obj_IsDeleted(objs)){
	ObjRender_SetAngleZ(objs,ang/angsp);
	ang++;
	yield;
	}
	}
	
	task Move(objs,type){
	let speed=1;
	if(type=="RIGHT"){
	descent(i in 10..39){
	ObjRender_SetX(objs,ObjRender_GetX(objs)+speed*3.50);
	speed=i/60;
	yield;
	}ascent(i in 41..290){
	ObjRender_SetX(objs,ObjRender_GetX(objs)+speed*0.80); 
	speed = 10/65;
	yield;
	}ascent(i in 10..60){
	ObjRender_SetX(objs,ObjRender_GetX(objs)+speed*3.50);
	speed=i/55;
	yield;
	}
	}else if(type=="LEFT"){
	descent(i in 10..39){
	ObjRender_SetX(objs,ObjRender_GetX(objs)-speed*3.50);
	speed=i/60;
	yield;
	}ascent(i in 41..290){
	ObjRender_SetX(objs,ObjRender_GetX(objs)-speed*0.80); 
	speed = 10/65;
	yield;
	}ascent(i in 10..60){
	ObjRender_SetX(objs,ObjRender_GetX(objs)-speed*3.50);
	speed=i/55;
	yield;
	}	
	}
	}
	}

function CreateEffectObject(px,py,img,blendtype,left,top,right,bottom){
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
 LoadTexture(img); ObjPrim_SetTexture(obj,img); 
ObjSprite2D_SetSourceRect(obj,left,top,right,bottom); 
ObjSprite2D_SetDestCenter(obj); if(blendtype=="ALPHA")
{ ObjRender_SetBlendType(obj,BLEND_ALPHA); } if(blendtype=="RGB")
{ ObjRender_SetBlendType(obj,BLEND_ADD_RGB); } if(blendtype=="ARGB")
{ ObjRender_SetBlendType(obj,BLEND_ADD_ARGB); } 
ObjRender_SetPosition(obj,px,py,0); 
ObjMove_SetPosition(obj,px,py,); 
SetAutoDeleteObject(true);
return obj; 
} 


function ReturnColor(type){
	if(type=="RED"){return [255,0,0];}
	if(type=="ORANGE"){return [255,128,0];}
	if(type=="YELLOW"){return [255,255,0];}
	if(type=="GREEN"){return [0,255,0];}
	if(type=="BLUE"){return [0,0,255];}
	if(type=="PURPLE"){return [255,0,255];}
	if(type=="WHITE"){return [255,255,255];}
	}
