Gauge cell method for simulation studies of phase transitions in confined systems