/*-----重力設定--------------------------*/
gravity = 0;
gravity_direction = 0;

with(objEnemyEdit){ if(Edit_Play) exit; }

/*-----キャラクタとの情報の取得---------------*/
playerDistance = point_distance(x,y,objPlayerDoll.x,objPlayerDoll.y);
playerDirection = point_direction(x,y,objPlayerDoll.x,objPlayerDoll.y);

/*-----モーション毎の処理--------------------*/
if(RECV_DAMAGE) playEnemySound(SOUND_DAMAGE);

if(!ChangeMotion){
	switch(MotionNum){
		case STAND :
			speed *= 0.9;
			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* 近づいたら動く */
			if(100<playerDistance && playerDistance<400){ MotionChange(MOVE,0,5); break; }
			break;
		case MOVE :
			motion_add(playerDirection-20+40*random(1),1);
			if(speed>10) speed = 10;

			/* 相手の方を向く */
			if(objPlayerDoll.x > x) Direction = Right;
			else Direction = Left;

			/* 近づきすぎたり離れたりしたら止まる */
			if( 100>playerDistance || playerDistance>400){ MotionChange(STAND,0,5); break; }
			break;
		case DEAD_MOTION :
			if(KeyFrmNum==1 && KEYFRAME){
				sound_play(sndHit02);
				Fluid(x,y,c_olive,35,5,20,0,180,0.5);
				Quake(5,5);
			}
			if(MOTIONEND){
				effect_create_above(ef_explosion,x,y,1,c_olive);
				Flash(c_white,0.1,0.05);
				Fluid(x,y,c_olive,5,5,20,0,180,0.5);
				Quake(5,5);
				sound_play(sndFluid);
				instance_destroy();
			}
			break;
	}
}