Gunmen opened fire on police guarding the construction of a dam in the Balochistan province, the deputy commissioner says.