// 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; }
// Determine if the given game object is on the surface of the cube piece protected bool IsPieceOnSurfaceOfCubeFace(GameObject givenPieceFace, RotatableCubeFaceIndex cubeFaceIndex) { // If the piece is not contained in the face, return false var givenPiece = givenPieceFace.transform.parent; if (!this.cubeFaceList[cubeFaceIndex].Contains(givenPiece.gameObject)) { return false; } // Get the blakc base of the given piece Transform givenPieceBase = null; for(int i =0;i < givenPiece.childCount; i ++) { givenPieceBase = givenPiece.GetChild(i); if(givenPieceBase.transform.localScale.x == 2) { break; } } if (cubeFaceIndex == RotatableCubeFaceIndex.Top || cubeFaceIndex == RotatableCubeFaceIndex.Bottom) { return givenPieceFace.transform.position.y != givenPieceBase.transform.position.y; } if (cubeFaceIndex == RotatableCubeFaceIndex.Left || cubeFaceIndex == RotatableCubeFaceIndex.Right) { return givenPieceFace.transform.position.x != givenPieceBase.transform.position.x; } return givenPieceFace.transform.position.z != givenPieceBase.transform.position.z; }
// 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(); }
public JobStabilize(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; }
public JobRotateFface(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube, float degreesLeft, float rotationVelocity) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; this.degreesLeft = degreesLeft; this.rotationVelocity = rotationVelocity; }
public JobRotateByMouse(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube, bool isClockwise, bool isMainMouseX) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; this.isClockwise = isClockwise; this.isMainMouseX = isMainMouseX; }
public JobReassignFaces(RotatableCubeFaceIndex cubeFaceIndex, CubeControl cube) { this.cubeFaceIndex = cubeFaceIndex; this.cube = cube; }
public MoveDone(RotatableCubeFaceIndex faceRotated, RotationMethodIndex rotationMethod) { this.faceRotated = faceRotated; this.rotationMethod = rotationMethod; }