public void ConstructOneFloor(int floor, string[] field) { _floor = floor; var height = field.Length; var width = field[0].Length; var expectedHeight = _field.GetUpperBound(1) + 1; var expectedWidth = _field.GetUpperBound(2) + 1; if (expectedHeight != height || expectedWidth != width) { throw new Exception(); } while (true) { var mustRunAgain = false; for (var y = 0; y < height; y++) { for (var x = 0; x < width; x++) { if (!_field[floor, y, x].IsNone) { continue; } switch (field[y][x]) { case ' ': _field[floor, y, x] = new PlayingFieldSquare(); break; case 'X': _field[floor, y, x] = PlayingFieldSquare.CreateFlat(0); break; case 'D': _field[floor, y, x] = createSlopeSquare(x, y, true); mustRunAgain |= _field[floor, y, x].IsNone; break; case 'U': _field[floor, y, x] = createSlopeSquare(x, y, false); mustRunAgain |= _field[floor, y, x].IsNone; break; } } } if (!mustRunAgain) { return; } } }
public void ConstructOneFloor(int floor, string[] field) { _floor = floor; var height = field.Length; var width = field[0].Length; var expectedHeight = _field.GetUpperBound(1) + 1; var expectedWidth = _field.GetUpperBound(2) + 1; if (expectedHeight != height || expectedWidth != width) throw new Exception(); while (true) { var mustRunAgain = false; for (var y = 0; y < height; y++) for (var x = 0; x < width; x++) { if (!_field[floor, y, x].IsNone ) continue; switch (field[y][x]) { case ' ': _field[floor, y, x] = new PlayingFieldSquare(); break; case 'X': _field[floor, y, x] = PlayingFieldSquare.CreateFlat(0); break; case 'D': _field[floor, y, x] = createSlopeSquare(x, y, true); mustRunAgain |= _field[floor, y, x].IsNone; break; case 'U': _field[floor, y, x] = createSlopeSquare(x, y, false); mustRunAgain |= _field[floor, y, x].IsNone; break; } } if (!mustRunAgain) return; } }
public PlayingFieldBuilder( PlayingFieldSquare[,,] field) { _field = field; }