// Find the opposite move public static RotationMethodIndex FindOppositeMethod(RotationMethodIndex rotationMethodIndex) { switch (rotationMethodIndex) { case RotationMethodIndex.Counterclockwise: { return RotationMethodIndex.Clockwise; } case RotationMethodIndex.Clockwise: { return RotationMethodIndex.Counterclockwise; } case RotationMethodIndex.HalfCircle: { return RotationMethodIndex.HalfCircle; } default: { break; } } return RotationMethodIndex.None; }
// Give the degree corresponding to the rotation method private int GetDegreeFromRotationMethod(RotationMethodIndex rotationMethod) { switch (rotationMethod) { case RotationMethodIndex.Clockwise: return 90; case RotationMethodIndex.Counterclockwise: return -90; case RotationMethodIndex.HalfCircle: return 180; default: break; } return 0; }
// Rotate the given face with the given method protected void ReconfigureFacePiecesBasedOnRotation(RotatableCubeFaceIndex faceIndex, RotationMethodIndex rotationMethod) { if (rotationMethod == RotationMethodIndex.None) { return; } if (rotationMethod == RotationMethodIndex.Clockwise || rotationMethod == RotationMethodIndex.HalfCircle) { // Rotate the pieces themselves first this.cubeFaceList[faceIndex].RotatePiecesClockwise(); var affectedFaceList = this.cubeFaceRotationRulesList[faceIndex]; // Initialize the first row to be inserted var replaceRow = affectedFaceList.AffectedFaces[3].GetPiecesInRow(affectedFaceList.AffectedRowIndex[3]); for (int i = 0; i < 4; i++) { replaceRow = affectedFaceList.AffectedFaces[i].ReplaceRow( affectedFaceList.AffectedRowIndex[i], replaceRow, affectedFaceList.RequiredToFlipFromPrevious[i]); } this.ReassignCenterPieceFaces(); // Rotate the blocks themselves // this.cubeFaceList[faceIndex].Rotate(90); // If half circle, do it again if (rotationMethod == RotationMethodIndex.HalfCircle) { this.ReconfigureFacePiecesBasedOnRotation(faceIndex, RotationMethodIndex.Clockwise); this.ReassignCenterPieceFaces(); } return; } else { // Rotate the pieces themselves first this.cubeFaceList[faceIndex].RotatePiecesCounterclockwise(); var affectedFaceList = this.cubeFaceRotationRulesList[faceIndex]; // Initialize the first row to be inserted var replaceRow = affectedFaceList.AffectedFaces[0].GetPiecesInRow(affectedFaceList.AffectedRowIndex[0]); for (int i = 3; i >= 0; i--) { replaceRow = affectedFaceList.AffectedFaces[i].ReplaceRow( affectedFaceList.AffectedRowIndex[i], replaceRow, // for face 0 to rotate to face 1, use the flipped bool for face 1 // thus, use i+1. If i+1>3, then that means it's the first cube. use 0 instead affectedFaceList.RequiredToFlipFromPrevious[i + 1 > 3 ? 0 : i + 1]); } // Rotate the blocks themselves // this.cubeFaceList[faceIndex].Rotate(-90); } this.ReassignCenterPieceFaces(); }
// Rotate the given face based on the rotation method protected void RotateFaceBasedOnMethod(RotatableCubeFaceIndex cubeFaceIndex, RotationMethodIndex rotationMethod) { switch (rotationMethod) { case RotationMethodIndex.Clockwise: { this.cubeFaceList[cubeFaceIndex].Rotate(90); return; } case RotationMethodIndex.Counterclockwise: { this.cubeFaceList[cubeFaceIndex].Rotate(-90); return; } case RotationMethodIndex.HalfCircle: { this.cubeFaceList[cubeFaceIndex].Rotate(180); return; } default: { break; } } return; }
public MoveDone(RotatableCubeFaceIndex faceRotated, RotationMethodIndex rotationMethod) { this.faceRotated = faceRotated; this.rotationMethod = rotationMethod; }