public bool CallNext(IHasQueue obj) { if (commandQueue == null) { return(false); } if (commandQueue.Count == queueIndex) { messageBox.ClearStepIndicator(); obj.QueueComplete(); queueIndex = 0; return(false); } Commands cmd = commandQueue[queueIndex]; messageBox.SetStepIndicator(queueIndex); queueIndex++; switch (cmd) { case Commands.LookUp: return(((IMoveable)obj).TurnTowards(MoveComponent.Direction.N)); case Commands.LookDown: return(((IMoveable)obj).TurnTowards(MoveComponent.Direction.S)); case Commands.LookLeft: return(((IMoveable)obj).TurnTowards(MoveComponent.Direction.W)); case Commands.LookRight: return(((IMoveable)obj).TurnTowards(MoveComponent.Direction.E)); case Commands.MoveForward: return(((IMoveable)obj).MoveForward()); case Commands.MoveBackward: return(((IMoveable)obj).MoveBackward()); case Commands.GrabObject: return(((ICanGrab)obj).GrabObject()); case Commands.ReleaseObject: return(((ICanGrab)obj).ReleaseObject()); default: return(false); } }