//
//敵ショットのタスク
//

task once_system_TaskEnemyShotMain(){

return;
//test_shot();

	loop{
		let check = GetCommonDataDefaultEx("SPHERIA_ENEMY", "ENEMY_SHOT",[]);
		
		while(length(check) != 0){
			let array = check[0];
			system_TaskCreateEnemyShot(array[1],array[2],array[3],array[4],array[5]);
			check = erase(check, 0);
		}
		SetCommonDataEx("SPHERIA_ENEMY", "ENEMY_SHOT", []);
		
		yield;
	}
}//end task


task system_TaskCreateEnemyShot(let x, let y, let speed, let angle, let graphic){

	let obj = REMY_CreateShotObject(x, y, speed, angle, graphic, 10);
	let flag_field_inside = true;
	let old_x; 
	let old_y; 
	let old_angle; 


	while(!Obj_BeDeleted(obj)){
		flag_field_inside = !REMY_IsOutOfClip(Obj_GetX(obj), Obj_GetY(obj),0);
		old_angle = Obj_GetAngle(obj); 
		yield;
	}
	if(flag_field_inside){
		PlaySE(se_Reflect);
		system_AddWeight(-5);
		loop(10){
			system_TaskWeightItemLost(system_GetSphereX(), system_GetSphereY(), old_angle+180);
		}
		yield;
	}


}//end task





//////
task test_shot(){
	let counter = 0;
	loop{
		counter++;
		loop(10){yield;}
		let array = GetCommonDataDefaultEx("SPHERIA_ENEMY", "ENEMY_SHOT",[]);
		array = array ~ [[0, GetCenterX(), GetCenterY(), 0.8, 12 * counter, RED01]];
		SetCommonDataEx("SPHERIA_ENEMY", "ENEMY_SHOT",array);
	}
}
