
task once_system_TaskLogoMain(){

	local{
		let obj = REMY_CreateEffectObject(img_Sphere, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 530, GetCenterY());
		ObjEffect_SetScale(obj, 200/32, (GetClipMaxY()-GetClipMinY())/32);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("SPHERE_WHITE"), 0, 0, 100, 0, 0, 0);
	}

	local{
		let obj = REMY_CreateEffectObject(img_Words, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 530, 100);
		ObjEffect_SetScale(obj, 0.7,0.7);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("WORDS_TITLE"), 0, 0, 255, 200, 200, 200);
	}

}

task once_system_TaskLifeMain(){

	let life_val = 0;

	ascent(i in 0..5){
		DrawLife(i);
	}

	local{
		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 480, 315);
		ObjEffect_SetScale(obj, 0.7,0.7);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("TEXT_LIFE"), 0, 0, 255, 200, 200, 200);
	}

	loop{
		life_val = GetCommonDataDefaultEx("SPHERIA_PLAYER", "PLAYER_LIFE", 1);
		loop(15){yield;}
	}

	task DrawLife(let order){

		let obj = REMY_CreateEffectObject(img_Life, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 460 + order*30, 340);

		loop{
			let val = trunc(REMY_GetNumLimited(life_val-(100 * order), 0, 100, false)/10);
			let rect = [32*val, 0, 32*(val+1), 32];
			REMY_SetObjectVertexSquare(obj, rect, 0, 0, 255, 200, 200, 200);
			loop(15){yield;}
		}
	}

}//end task


task once_system_TaskDrawWeightParam(){

	let weight_val = 0;
	
	ascent(i in 0..6){
		DrawWeight(i);
	}

	local{
		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 496, 375);
		ObjEffect_SetScale(obj, 0.7,0.7);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("TEXT_WEIGHT"), 0, 0, 255, 255, 255, 255);
	}

	task DrawWeight(let order){

		let obj = REMY_CreateEffectObject(img_MagicMini, 4, 8);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("MAGIC_MIN"), 0, 0, 255, 200, 200, 200);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 460 + order*27, 400);

		let max_weight = const_SphereWeightUnit[order+1];
		let min_weight = const_SphereWeightUnit[order];

		loop{
			let val = trunc(REMY_GetNumLimited(system_GetWeight()-(min_weight), 0, (max_weight-min_weight), false) / (max_weight-min_weight) * 10 );
			REMY_SetObjectColorSquare(obj, [200, 255][val == 10], 255, [200, 255][val == 10],[200, 255][val == 10]);
			ObjEffect_SetScale(obj, 0.1 + 0.5 *(val/10) , 0.1 + 0.5 *(val/10));
			loop(15){yield;}
		}
	}

}//end task

task once_system_TaskScoreMain(){

	ascent(i in 0..9){
		DrawScore(i);
	}
	ascent(i in 0..4){
		DrawCombo(i);
	}

	local{
		let obj = REMY_CreateEffectObject(img_Sphere, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 530, 250);
		ObjEffect_SetScale(obj, 0.5, 0.8);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("SPHERE_GAUGE_FRAME"), -16*5, 0, 255, 200, 200, 200);
	}
	DrawComboGauge();

	local{
		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 480, 180);
		ObjEffect_SetScale(obj, 0.7,0.7);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("TEXT_SCORE"), 0, 0, 255, 200, 200, 200);
	}
	local{
		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 480, 250);
		ObjEffect_SetScale(obj, 0.7,0.7);
		REMY_SetObjectVertexSquare(obj, system_GetGraphicRect("TEXT_COMBO"), 0, 0, 255, 200, 200, 200);
	}

	task DrawScore(let order){

		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 600 - order*18, 210);
		ObjEffect_SetScale(obj, 1.0,1.0);

		loop{
			let val = trunc(GetScore()/(10^order)%10);
			REMY_SetObjectVertexSquare(obj, system_GetGraphicRectNum(val), 0, 0, 255, 200, 200, 200);
			loop(15){yield;}
		}
	}

	task DrawCombo(let order){

		let obj = REMY_CreateEffectObject(img_CountNum, 4, 8);
		ObjEffect_SetRenderState(obj, ALPHA);
		Obj_SetPosition(obj, 600 - order*18, 280);
		ObjEffect_SetScale(obj, 1.0,1.0);

		loop{
			let val = trunc(system_GetScoreComboCount()/(10^order)%10);
			REMY_SetObjectVertexSquare(obj, system_GetGraphicRectNum(val), 0, 0, 255, 200, 200, 200);
			loop(4){yield;}
		}
	}

	task DrawComboGauge(){

		let obj = REMY_CreateEffectObject(img_Sphere, 4, 8);
		ObjEffect_SetRenderState(obj, ADD);
		Obj_SetPosition(obj, 530, 250);
		ObjEffect_SetScale(obj, 0.5, 0.8);
		let rect = system_GetGraphicRect("SPHERE_GAUGE01");
		let gauge_max = rect[2]-rect[0];

		let counter = 0;
		loop{
			let val = trunc(gauge_max * system_GetScoreComboTime()/300);
			rect = system_GetGraphicRect(["SPHERE_GAUGE01","SPHERE_GAUGE02","SPHERE_GAUGE03"][counter%3]);
			REMY_SetObjectVertexSquare(obj, [rect[0], rect[1], rect[0] + val, rect[3]], -val/2, 0, 255, 200, 200, 200);
			loop(4){yield;}
			counter++;
		}
	}

}//end task


task once_system_TaskEnemyLifeMain(){

	let life_max = 0;

	let obj_frame = REMY_CreateEffectObject(img_Sphere, 4, 5);
	ObjEffect_SetRenderState(obj_frame, ALPHA);
	Obj_SetPosition(obj_frame, GetClipMinX()+ 15, 26);
	ObjEffect_SetScale(obj_frame, 2.1, 1.2);
	REMY_SetObjectVertexSquare(obj_frame, system_GetGraphicRect("SPHERE_GAUGE_FRAME"), -16*5, 0, 0, 0 , 0, 0);

	DrawEnemyLifeGauge();
	loop{
		while( GetCommonDataEx("SPHERIA_ENEMY", "ENEMY_BOSSLIFE_MAX") == 0 ){ loop(20){yield;} }
		REMY_SetObjectColorSquare(obj_frame, 255, 255, 255, 255);
		life_max = GetCommonDataEx("SPHERIA_ENEMY", "ENEMY_BOSSLIFE_MAX");
		SetCommonDataEx("SPHERIA_ENEMY", "ENEMY_BOSSLIFE_MAX", 0);
		yield;
	}

	task DrawEnemyLifeGauge(){

		let obj = REMY_CreateEffectObject(img_Sphere, 4, 5);
		ObjEffect_SetRenderState(obj, ADD);
		Obj_SetPosition(obj, GetClipMinX()+ 15, 26);
		ObjEffect_SetScale(obj, 2.1, 1.2);
		let rect = system_GetGraphicRect("SPHERE_GAUGE01");
		let gauge_max = rect[2]-rect[0];
		REMY_SetObjectVertexSquare(obj, [rect[0], rect[1], rect[0], rect[3]], 0, 0, 0, 0, 0, 0);

		let counter = 0;
		loop{
			while(life_max == 0){ yield; }
			let val = trunc(gauge_max * (GetEnemyLife()-default_LifeBase)/life_max);
			if(val < 0){ val = 0; }
			rect = system_GetGraphicRect(["SPHERE_GAUGE01","SPHERE_GAUGE02","SPHERE_GAUGE03"][trunc(counter/2)%3]);
			REMY_SetObjectVertexSquare(obj, [rect[0], rect[1], rect[0] + val, rect[3]], -val/2, 0, 255, 250, 250, 200);
			loop(4){yield;}
			counter++;
		}

	}

}
