예제 #1
0
 private static int GetSliceScale(Axis axis, Piece piece)
 {
     return axis == Axis.FrontBack ? piece.Size.Length : axis == Axis.TopBottom ? piece.Size.Height : piece.Size.Width;
 }
예제 #2
0
 private void AddSlice(Axis axis, Piece piece)
 {
     if (piece.HasColorsOnSides(new[] { edges[(int)axis][0] }))
         slices[(int)axis].Insert(0, GetSliceScale(axis, piece));
     else if (piece.HasNoColorsOnSides(new[] { edges[(int)axis][1] }))
     {
         if (slices[(int)axis].Count == 0)
             slices[(int)axis].Add(GetSliceScale(axis, piece));
         else
             slices[(int)axis].Insert(slices[(int)axis].Count - (isSlicingFinished[(int)axis] ? 1 : 0), GetSliceScale(axis, piece));
     }
     else
     {
         slices[(int)axis].Add(GetSliceScale(axis, piece));
         isSlicingFinished[(int)axis] = true;
     }
 }
예제 #3
0
 public void AddInitialData(int length, int height, int width, string coloring)
 {
     basePiece = new Piece(new Size { Length = length, Height = height, Width = width }, coloring);
 }
예제 #4
0
 public static Piece GetDefiningPiece(int length, int height, int width, string coloring, Piece basePiece)
 {
     Piece newPiece = new Piece(new Size { Length = length, Height = height, Width = width }, coloring);
     while (!newPiece.MatchBasePiece(basePiece))
         newPiece.CommitNextRotation();
     return newPiece;
 }
예제 #5
0
 public static string FormColoring(Piece basePiece, params bool[] coloring)
 {
     return new String(Enumerable.Range(0, 6).Select(e => coloring[e] ? basePiece.Coloring[e] : '.').ToArray());
 }
예제 #6
0
 public static bool MatchBasePiece(this Piece piece, Piece basePiece)
 {
     return Enumerable.Range(0, 6).All(e =>
         piece.Coloring[(int)piece.Rotation[e]] == '.' || piece.Coloring[(int)piece.Rotation[e]] == basePiece.Coloring[e]);
 }
예제 #7
0
 public bool Equals(Piece other)
 {
     return Identity.Equals(other.Identity);
 }