
function stage_WaitForEnemyDefeat(){

	while(GetEnemyNum()>0){
		yield;
	}

}//end function

task stage_CreateEnemyWithDanger(let x, let y, let wait, let type, let ex, let ey, let spd, let ang, let argument){

	stage_Danger(x, y);
	loop(wait){yield;}
	CreateEnemyFromFile(system_GetEnemyPath(type), ex, ey, spd, ang, argument );

}//end task 

task stage_Danger(let x, let y){

	let obj = REMY_CreateEffectObject(img_Text, 4, 6);
	let rect = system_GetGraphicRect("DANGER");
	REMY_SetObjectVertexSquare(obj, rect, 0, 0, 200, 220, 205, 25);
	Obj_SetPosition(obj,  x,  y);

	ascent(i in 0..50){
		ObjEffect_SetScale(obj, 0.3 + 0.1*(i/50), 0.6 + 0.1*(i/50));
		REMY_SetObjectColorSquare(obj, 220*(1-(i/50))*[1,2,1,2][i%4], 220, 205, 25);
		ObjEffect_SetRenderState(obj,[ADD,ADD,SUBTRACT,SUBTRACT][i%4]);
		yield;
	}
	Obj_Delete(obj);

}//end task

task stage_TaskGameClear(let type){

	loop(20){yield;}
	Screen();
	Word();
	loop(50){yield;}
	Word2();

	task Screen(){

		let obj = REMY_CreateEffectObject(img_Sphere, 4, 6);
		let rect = system_GetGraphicRect("SPHERE_WHITE");
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, GetCenterX(), GetCenterY()+60);


		ascent(i in 0..8){
			ObjEffect_SetScale(obj, 20, 8 * (i/7));
			REMY_SetObjectVertexSquare(obj, rect, 0, 0, 200 * (i/8), 50, 50, 50);
			loop(4){ yield; }
		}

		loop(500){ yield; }
		Obj_Delete(obj);


	}

	task Word(){
		let obj = REMY_CreateEffectObject(img_Words, 20, 6);
		let rect = system_GetGraphicRect("WORDS_GAMECLEAR");
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, GetCenterX()-(rect[2]-rect[0]), GetCenterY() - (rect[3]-rect[1]));
		ObjEffect_SetScale(obj, 2, 2);

		ascent(i in 0..20){
			ObjEffect_SetVertexXY(obj, i, (rect[2]-rect[0])*(trunc(i/2)/9), (rect[3]-rect[1])*(i%2));
			ObjEffect_SetVertexUV(obj, i, rect[0] + (rect[2]-rect[0])*(trunc(i/2)/9), rect[1] + (rect[3]-rect[1])*(i%2) );
			ObjEffect_SetVertexColor(obj, i, 255, 255, 255, 255);
		}

		ascent(j in 0..21){
			ascent(i in 0..20){
				ObjEffect_SetVertexXY(obj, i, (rect[2]-rect[0])*(trunc(i/2)/9), REMY_GetNumMin((rect[3]-rect[1])*(i%2)*((j+i)/20), rect[3]-rect[1]));
			}
			loop(2){ yield; }
		}

		loop(500){ yield; }
		Obj_Delete(obj);

	}

	task Word2(){
		let obj = REMY_CreateEffectObject(img_Words, 20, 6);
		let rect = system_GetGraphicRect(["WORDS_CLEARTEXT1","WORDS_CLEARTEXT2"][type]);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, GetCenterX()-(rect[2]-rect[0]), GetCenterY() - (rect[3]-rect[1]) + 120);
		ObjEffect_SetScale(obj, 1.4, 1.4);

		ascent(i in 0..20){
			ObjEffect_SetVertexXY(obj, i, (rect[2]-rect[0])*(trunc(i/2)/9), (rect[3]-rect[1])*(i%2));
			ObjEffect_SetVertexUV(obj, i, rect[0] + (rect[2]-rect[0])*(trunc(i/2)/9), rect[1] + (rect[3]-rect[1])*(i%2) );
			ObjEffect_SetVertexColor(obj, i, 255, 255, 128 + 128*(i/20), 128+128*(i/20));
		}

		ascent(j in 0..21){
			ascent(i in 0..20){
				ObjEffect_SetVertexXY(obj, i, (rect[2]-rect[0])*(trunc(i/2)/9), REMY_GetNumMin((rect[3]-rect[1])*(i%2)*((j+i)/20), rect[3]-rect[1]));
			}
			loop(1){ yield; }
		}

		loop(500){ yield; }
		Obj_Delete(obj);

	}




}//end task


function stage_ComboStop(){
	system_SetScoreComboStopFlag(true);
}
function stage_ComboStart(){
	system_SetScoreComboStopFlag(false);
}

//ゲームオーバーのときに止める
function stage_StopGameover()
{
	while(system_IsGameOver()){ yield; }
}//end function

function stage_Ending()
{
	
	system_Ending();
	loop{ yield; }
}

