public PieceOrientation RotateClockwise90Degrees() { var orientation = new PieceOrientation { Width = Height, Height = Width, IsFilledIn = new bool[Width, Height], IsOuty = new bool[Width, Height], }; for (var y = 0; y < orientation.Height; y++) for (var x = 0; x < orientation.Width; x++) { var oldY = (orientation.Width - 1) - x; var oldX = y; orientation.IsFilledIn[y, x] = IsFilledIn[oldY, oldX]; orientation.IsOuty[y, x] = IsOuty[oldY, oldX]; } return orientation; }
public Piece(bool[,] isFilledIn, bool isTopLeftOuty, string code) { var orientation1 = new PieceOrientation { Width = isFilledIn.GetUpperBound(1) + 1, Height = isFilledIn.GetUpperBound(0) + 1, IsFilledIn = isFilledIn, }; orientation1.IsOuty = new bool[orientation1.Height, orientation1.Width]; for(var y = 0; y < orientation1.Height; y++) for (var x = 0; x < orientation1.Width; x++) orientation1.IsOuty[y, x] = ((y + x)%2 == 0) ? isTopLeftOuty : !isTopLeftOuty; var orientation2 = orientation1.RotateClockwise90Degrees(); var orientation3 = orientation2.RotateClockwise90Degrees(); var orientation4 = orientation3.RotateClockwise90Degrees(); Orientations = new List<PieceOrientation>{ orientation1, orientation2, orientation3, orientation4}; Code = code; }