private void SetFacePosition(VisualCube c, VisualCubeFace fToTurn, CubeFaceType desiredType) { if (fToTurn.FaceType != desiredType) { c.TurnCube(fToTurn, desiredType); } }
/// <summary> /// Get a list of all corners that has the same side of the face. /// </summary> /// <param name="fSearch">Face to search</param> /// <returns>Returns a list with all the corners</returns> private List<VisualCubeBlock> GetCornersFromSameSide(VisualCubeFace fSearch) { List<VisualCubeBlock> lsBlocks = new List<VisualCubeBlock>(); foreach (VisualCubeBlock item in fSearch.GetBlocks()) { if (item.Color.Equals(fSearch.FaceColor) && item.IsCorner()) lsBlocks.Add(item); } return lsBlocks; }
/// <summary> /// Gets the start face to organize the corners /// </summary> /// <param name="c">Cube to search</param> /// <param name="blocks">Returns all the blocks with same side of the face</param> /// <returns>Returns the selected CubeFace.</returns> private VisualCubeFace GetStartFace(VisualCube c, out List<VisualCubeBlock> blocks) { VisualCubeFace selFace = new VisualCubeFace(); blocks = new List<VisualCubeBlock>(); foreach (VisualCubeFace item in c.GetFaces()) { blocks = GetCornersFromSameSide(item); if (blocks.Count > 0) { //TODO: Select best face to get the corner. selFace = item; break; } } return selFace; }
/// <summary> /// Turns, if it is necessary, the cube to the face become the desired type. /// </summary> /// <param name="f">Face to turn</param> /// <param name="desiredType">Desired type for the face</param> public void TurnCube(VisualCubeFace f, CubeFaceType desiredType) { if (f.FaceType != desiredType) { Coordinate coord = GetVariationMovement(f.FaceType, desiredType); TurnCube(coord); } }
/// <summary> /// Adds/Udates a face to the cube /// </summary> /// <param name="face">The face to be added/Udated</param> public void AddFace(VisualCubeFace face) { int foundIndex = -1; for (int i = 0; i < _faces.Count; i++) { if (_faces[i].FaceType == face.FaceType) { foundIndex = i; break; } } if (foundIndex == -1) _faces.Add(face.Clone()); else { _faces[foundIndex] = face.Clone(); } }
private void btnBuildDefaultCube_Click(object sender, EventArgs e) { Array facesArray = Enum.GetValues(typeof(CubeFaceType)); Array squaresArray = Enum.GetValues(typeof(CubeFaceletType)); CubeFaceColor[] colors = new CubeFaceColor[] { CubeFaceColor.R, CubeFaceColor.O, CubeFaceColor.B, CubeFaceColor.G, CubeFaceColor.W, CubeFaceColor.Y }; for (int i = 0; i < facesArray.Length; i++) { VisualCubeFace face = new VisualCubeFace(); face.FaceType = (CubeFaceType)facesArray.GetValue(i); foreach (CubeFaceletType item in squaresArray) { VisualCubeBlock block = new VisualCubeBlock(); block.Square = item; block.Color = colors[i]; face.AddBlock(block.Clone(), false); block.Dispose(); } this.CurrentCube.AddFace(face.Clone()); face.Dispose(); } picbCubeDiagram.Invalidate(); }