Random linear movement in 2D

I’m trying to make a bomberman clone and I’m struggling with the enemy AI.What I want is for the ai to move in straight line but it keeps bounsing and hiting the walls a lot, not moving in straight line. This is what I have right now, it works but it still bounces while trying to snap to the right coordinates:

void FixedUpdate() {
		if (!dead) {
			directionTimer += Time.deltaTime;
			if (directionTimer >= directionTime) {
				directionTimer = 0f;
				ChangeDirection();
			}
			
			if (left) {
				Vector3 pos = new Vector3(Vector3.left.x, Mathf.Round(transform.position.y) - transform.position.y, 0f);
				transform.Translate(pos * speed * Time.deltaTime);
			} else if (right) {
				Vector3 pos = new Vector3(Vector3.right.x, Mathf.Round(transform.position.y) - transform.position.y, 0f);
				transform.Translate(pos * speed * Time.deltaTime);
			} else if (up) {
				Vector3 pos = new Vector3(Mathf.Round(transform.position.x) - transform.position.x, Vector3.up.y, 0f);
				transform.Translate(pos * speed * Time.deltaTime);
			} else if (down) {
				Vector3 pos = new Vector3(Mathf.Round(transform.position.x) - transform.position.x, Vector3.down.y, 0f);
				transform.Translate(pos * speed * Time.deltaTime);
			}
			
		} else {
			timer += Time.deltaTime;
			if (timer >= time) {
				DestroyMyself();
			}
			if (playAnim) {
				anim.SetTrigger ("Dead");
				playAnim = false;
				collider.isTrigger = true;
			}
			
		}
	}

Any way to make it move only in straight lines like this?
alt text

You can try the game here: link text
Thanks!

Firstly, you need 2d array of your map which contains empty or wall nodes, then, you need algorithm like that :

foreach (aliveEnemy)
{
    while(true)
    {
        select destination node from available nodes // which are not walls, not direction you came
        move destination // in coroutine
    }
}

Also, check isTrigger for preventing collisions between enemies and walls.