I think you should not try to hardcode this behavior as a series of if-elses like you're doing, because this will make it very difficult to extend or change if you need different values, or to add more positions in the path.
Instead look into adding the capability of following any path to your entity. Here's an example (I'll give the example in 2D but it should be the same for 3D), but there are certainly many ways to do this.
Suppose you're starting with:
class Entity
{
public Vector2 position;
public float speed;
}
First add this helper method to the class, which moves the entity towards a destination and returns true when the destination has been reached:
private bool MoveTowardsPoint(Vector2 goal, float elapsed)
{
// If we're already at the goal return immediatly
if(position == goal) return true;
// Find direction from current position to goal
Vector2 direction = Vector2.Normalize(goal - position);
// Move in that direction
position += direction * speed * elapsed;
// If we moved PAST the goal, move it back to the goal
if (Math.Abs(Vector2.Dot(direction, Vector2.Normalize(goal - position)) + 1) < 0.1f)
position = goal;
// Return whether we've reached the goal or not
return position == goal;
}
Then add a list of positions to your entity which will hold the path for him to follow:
class Entity
{
List<Vector2> path = new List<Vector2>();
}
And an update method that always moves the entity towards the next position in the path:
public void Update(float elapsed)
{
if(path.Count > 0 && MoveTowardsPoint(path[0], elapsed))
path.RemoveAt(0);
}
Finally, to make the entity follow the points you specified and make it repeat, add something like the code below to the Update method:
if(path.Count == 0)
{
path.Add(new Vector2(0, 200));
path.Add(new Vector2(200, 0);
path.Add(new Vector2(0, -200));
path.Add(new Vector2(-200, 0));
}