public void Manipulate(RubikCubeMoviment moviment) { List <Cube> movimentingPieces = new List <Cube>(); if (moviment.Axis == Axis.X) { if (moviment.Depth == Depth.First) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.X < 0); } else if (moviment.Depth == Depth.Second) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.X == 0); } else if (moviment.Depth == Depth.Third) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.X > 0); } Animation animation = new Animation(movimentingPieces, 90, moviment); this.pendingAnimation.Enqueue(animation); } else if (moviment.Axis == Axis.Y) { if (moviment.Depth == Depth.First) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Y > 0); } else if (moviment.Depth == Depth.Second) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Y == 0); } else if (moviment.Depth == Depth.Third) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Y < 0); } Animation animation = new Animation(movimentingPieces, 90, moviment); this.pendingAnimation.Enqueue(animation); } else if (moviment.Axis == Axis.Z) { if (moviment.Depth == Depth.First) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Z > 0); } else if (moviment.Depth == Depth.Second) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Z == 0); } else if (moviment.Depth == Depth.Third) { movimentingPieces = this.composingCubes.FindAll(pieces => pieces.Z < 0); } Animation animation = new Animation(movimentingPieces, 90, moviment); this.pendingAnimation.Enqueue(animation); } }
private void Transform(RubikCubeMoviment moviment) { if (moviment.Axis == Axis.X) { if (moviment.Spin == Spin.Clockwise) { if (this.Y < 0 && this.Z < 0) { this.Z = -this.Z; } else if (this.Y < 0 && this.Z > 0) { this.Y = -this.Y; } else if (this.Y > 0 && this.Z < 0) { this.Y = -this.Y; } else if (this.Y > 0 && this.Z > 0) { this.Z = -this.Z; } else if (this.Y == 0 && this.Z < 0) { this.Y = this.Z; this.Z = 0; } else if (this.Y == 0 && this.Z > 0) { this.Y = this.Z; this.Z = 0; } else if (this.Z == 0 && this.Y < 0) { this.Z = -this.Y; this.Y = 0; } else if (this.Z == 0 && this.Y > 0) { this.Z = -this.Y; this.Y = 0; } } else { if (this.Y < 0 && this.Z < 0) { this.Y = -this.Y; } else if (this.Y < 0 && this.Z > 0) { this.Z = -this.Z; } else if (this.Y > 0 && this.Z < 0) { this.Z = -this.Z; } else if (this.Y > 0 && this.Z > 0) { this.Y = -this.Y; } else if (this.Y == 0 && this.Z < 0) { this.Y = -this.Z; this.Z = 0; } else if (this.Y == 0 && this.Z > 0) { this.Y = -this.Z; this.Z = 0; } else if (this.Z == 0 && this.Y < 0) { this.Z = this.Y; this.Y = 0; } else if (this.Z == 0 && this.Y > 0) { this.Z = this.Y; this.Y = 0; } } } if (moviment.Axis == Axis.Y) { if (moviment.Spin == Spin.Clockwise) { if (this.X < 0 && this.Z < 0) { this.X = -this.X; } else if (this.X < 0 && this.Z > 0) { this.Z = -this.Z; } else if (this.X > 0 && this.Z < 0) { this.Z = -this.Z; } else if (this.X > 0 && this.Z > 0) { this.X = -this.X; } else if (this.X == 0 && this.Z < 0) { this.X = -this.Z; this.Z = 0; } else if (this.X == 0 && this.Z > 0) { this.X = -this.Z; this.Z = 0; } else if (this.Z == 0 && this.X < 0) { this.Z = this.X; this.X = 0; } else if (this.Z == 0 && this.X > 0) { this.Z = this.X; this.X = 0; } } else { if (this.X < 0 && this.Z < 0) { this.Z = -this.Z; } else if (this.X < 0 && this.Z > 0) { this.X = -this.X; } else if (this.X > 0 && this.Z < 0) { this.X = -this.X; } else if (this.X > 0 && this.Z > 0) { this.Z = -this.Z; } else if (this.X == 0 && this.Z < 0) { this.X = this.Z; this.Z = 0; } else if (this.X == 0 && this.Z > 0) { this.X = this.Z; this.Z = 0; } else if (this.Z == 0 && this.X < 0) { this.Z = -this.X; this.X = 0; } else if (this.Z == 0 && this.X > 0) { this.Z = -this.X; this.X = 0; } } } if (moviment.Axis == Axis.Z) { if (moviment.Spin == Spin.Clockwise) { if (this.X < 0 && this.Y < 0) { this.Y = -this.Y; } else if (this.X < 0 && this.Y > 0) { this.X = -this.X; } else if (this.X > 0 && this.Y < 0) { this.X = -this.X; } else if (this.X > 0 && this.Y > 0) { this.Y = -this.Y; } else if (this.X == 0 && this.Y < 0) { this.X = this.Y; this.Y = 0; } else if (this.X == 0 && this.Y > 0) { this.X = this.Z; this.Y = 0; } else if (this.Y == 0 && this.X < 0) { this.Y = -this.X; this.X = 0; } else if (this.Y == 0 && this.X > 0) { this.Y = -this.X; this.X = 0; } } else { if (this.X < 0 && this.Y < 0) { this.X = -this.X; } else if (this.X < 0 && this.Y > 0) { this.Y = -this.Y; } else if (this.X > 0 && this.Y < 0) { this.Y = -this.Y; } else if (this.X > 0 && this.Y > 0) { this.X = -this.X; } else if (this.X == 0 && this.Y < 0) { this.X = -this.Y; this.Y = 0; } else if (this.X == 0 && this.Y > 0) { this.X = -this.Z; this.Y = 0; } else if (this.Y == 0 && this.X < 0) { this.Y = this.X; this.X = 0; } else if (this.Y == 0 && this.X > 0) { this.Y = this.X; this.X = 0; } } } this.ResetTransforms(); }
public void Place(RubikCubeMoviment moviment) { this.faceColors.Rotate(moviment); this.Transform(moviment); this.ResetTransforms(); }
private void btnFirstYRight_Click(object sender, EventArgs e) { RubikCubeMoviment moviment = new RubikCubeMoviment(Depth.Third, Spin.Anticlockwise, Axis.Y); cGL.rubiksCube.Manipulate(moviment); }
private void btnThirdXUp_Click(object sender, EventArgs e) { RubikCubeMoviment moviment = new RubikCubeMoviment(Depth.Third, Spin.Clockwise, Axis.X); cGL.rubiksCube.Manipulate(moviment); }
private void btnSecondYLeft_Click(object sender, EventArgs e) { RubikCubeMoviment moviment = new RubikCubeMoviment(Depth.Second, Spin.Clockwise, Axis.Y); cGL.rubiksCube.Manipulate(moviment); }