Simulation of first-passage times for alternating Brownian motions